using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace DataUpdate { public partial class MessageForm : Form { public static string _type; public static string _shopcode; public static string _checkcode; public MessageForm(string maintype,string checkcode, string shopcode) { InitializeComponent(); this.Text = "系统提示"; _type = maintype; _shopcode = shopcode; _checkcode = checkcode; } private string strValue = ""; public string StrValue { get { return strValue; } set { strValue = value; } } private void btEnter_Click(object sender, EventArgs e) { string _time = ""; _time = textBox1.Text.Trim(); if (_time == "") { MessageBox.Show("请输入" + (_type == "CommoditySale" ? "单品信息" : "日结营收") + "上传成功确认码", "系统提示", MessageBoxButtons.OK); textBox1.Focus(); textBox1.SelectAll(); return; } else { if (_time != _checkcode) { if (_time.Length != 17) { MessageBox.Show((_type == "CommoditySale" ? "单品信息" : "日结营收") + "上传成功确认码不正确,请重新输入", "系统提示", MessageBoxButtons.OK); textBox1.Focus(); textBox1.SelectAll(); return; } try { if (_time.Substring(10, 6) != _shopcode) { MessageBox.Show((_type == "CommoditySale" ? "单品信息" : "日结营收") + "上传成功确认码不正确,请重新输入", "系统提示", MessageBoxButtons.OK); textBox1.Focus(); textBox1.SelectAll(); return; } _time = _time.Substring(0, _time.Length - 7); if (_time.Length != 10) { MessageBox.Show((_type == "CommoditySale" ? "单品信息" : "日结营收") + "上传成功确认码不正确,请重新输入", "系统提示", MessageBoxButtons.OK); textBox1.Focus(); textBox1.SelectAll(); return; } if (TimeHelper.ConvertLongDateTime(Convert.ToInt64(_time)) > DateTime.Now) { MessageBox.Show((_type == "CommoditySale" ? "单品信息" : "日结营收") + "上传成功确认码不正确,请重新输入", "系统提示", MessageBoxButtons.OK); textBox1.Focus(); textBox1.SelectAll(); return; } } catch (Exception ex) { MessageBox.Show((_type == "CommoditySale" ? "单品信息" : "日结营收") + "上传成功确认码不正确,请重新输入", "系统提示", MessageBoxButtons.OK); textBox1.Focus(); textBox1.SelectAll(); return; } } strValue = _time; //将文本框的值赋予窗体的属性 this.DialogResult = DialogResult.OK; this.Close(); } } private void btEsc_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) btEnter_Click(null, null); else if (e.KeyCode == Keys.Escape) btEsc_Click(null, null); } } }