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 InputMain : Form { private string strValue = ""; public string StrValue { get { return strValue; } set { strValue = value; } } public InputMain(string _type) { InitializeComponent(); string sql; if (_type == "EndAccount") { sql = "select endaccount_date from t_endaccount a where serverpartcode = '" + DataUpdate.ConfigUrationValues("serverpartcode", "") + "' and shopcode = '" + DataUpdate.ConfigUrationValues("shopcode", "") + "' and machinecode = '" + DataUpdate.ConfigUrationValues("machinecode", "") + "' and endaccount_date > datetime('" + DataUpdate.strUpload_Date(_type) + "') and not exists ( " + " select 1 from t_dataupdate b where a.endaccount_id = b.data_id and a.endaccount_date = b.data_date and b.data_type in (1001,1002))"; } else { sql = "select distinct(enddate) as endaccount_date from t_transfer_sale a where serverpartcode = '" + DataUpdate.ConfigUrationValues("serverpartcode", "") + "' and shopcode = '" + DataUpdate.ConfigUrationValues("shopcode", "") + "' and enddate > datetime('" + DataUpdate.strUpload_Date(_type) + "') and not exists ( " + "select 1 from t_dataupdate b where a.transfer_id = b.data_id and a.enddate = b.data_date and b.data_type = 3001)"; } string endaccount_date = DataUpdate.ExecuteDataSet(sql).Tables[0].Compute("min(endaccount_date)", "true").ToString(); DateTime _DateTime = Convert.ToDateTime(endaccount_date==""?DateTime.Today.AddDays(-1): DateTime.Parse(endaccount_date)); int _decimal = _DateTime.Subtract(Convert.ToDateTime(DateTime.Today.AddDays(-1))).Days; if (Convert.ToInt64(_DateTime.Subtract(Convert.ToDateTime(DataUpdate.strUpload_Date(_type))).TotalSeconds) > 0) lbl_days.Text = _decimal.ToString().PadLeft(2, '0'); daynum.Maximum = (_decimal <= 20 ? 30 : _decimal); daynum.Focus(); daynum.Select(0, daynum.Value.ToString().Length); } private void btEnter_Click(object sender, EventArgs e) { strValue = daynum.Value.ToString(); this.DialogResult = DialogResult.OK; this.Close(); } private void daynum_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) btEnter_Click(null, null); else if (e.KeyCode == Keys.Escape) this.DialogResult = DialogResult.Cancel; } } }