public ResionInput() { InitializeComponent(); this.dataGridView1.AutoGenerateColumns = false; this.dataGridView1.DataSource = ResionList; //ProvinceEntry test = new ProvinceEntry(); //test.provinceName = "广东"; //test.days = 2; //this.ProvinceList.Add(test); //ProvinceEntry test1 = new ProvinceEntry(); //test1.provinceName = "广西"; //test1.days = 3; //this.ProvinceList.Add(test1); //this.dataGridView1.bind //ProvinceList = new BindingList<ProvinceEntry>(); string command = string.Empty; command = "select * from ResionSet "; DataTable dt = conn.GetDataTableBySql(command); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { ResionEntry entry = new ResionEntry(); entry.Resion = dt.Rows[i]["Resion"].ToString(); entry.Days = int.Parse(dt.Rows[i]["Days"].ToString()); this.ResionList.Add(entry); } } }
private void btnInsert_Click(object sender, EventArgs e) { ResionEntry entry = new ResionEntry(); this.ResionList.Add(entry); }
private void Search() { ResultList = new List <ExpressReceiveEntry>(); string command = string.Empty; command = "select * from ExpressReceive where IsDelete =0 "; if (!string.IsNullOrWhiteSpace(this.txtExpressNo.Text)) { command += " and ExpressNo like '%" + this.txtExpressNo.Text + "%'"; } if (!string.IsNullOrWhiteSpace(this.txtCompanyName.Text)) { command += " and ExpressCompany like '%" + this.txtCompanyName.Text + "%'"; } if (!string.IsNullOrWhiteSpace(this.cmbResion.Text)) { command += " and Resion like '%" + this.cmbResion.Text + "%'"; } if (!string.IsNullOrWhiteSpace(this.cmbStatus.Text)) { command += " and Status like '%" + this.cmbStatus.Text + "%'"; } if (!string.IsNullOrWhiteSpace(this.cmbResult.Text)) { command += " and Result like '%" + this.cmbResult.Text + "%'"; } if (!string.IsNullOrWhiteSpace(this.txtCreateUser.Text)) { command += " and CreateUser like '%" + this.txtCreateUser.Text + "%'"; } if (this.timePickFrom.Value != null) { var timeFrom = this.timePickFrom.Value; timeFrom = timeFrom.AddHours(-this.timePickFrom.Value.Hour).AddMinutes(-this.timePickFrom.Value.Minute).AddSeconds(-this.timePickFrom.Value.Second); //DealTime //FinishTime if (this.cmbTime.Text == "录入时间") { command += " and convert(datetime,CreateTime) >='" + timeFrom.ToString("yyyy-MM-dd HH:mm:ss") + "'"; } else if (this.cmbTime.Text == "处理时间") { command += " and convert(datetime,DealTime) >='" + timeFrom.ToString("yyyy-MM-dd HH:mm:ss") + "'"; } else if (this.cmbTime.Text == "完结时间") { command += " and convert(datetime,FinishTime) >='" + timeFrom.ToString("yyyy-MM-dd HH:mm:ss") + "'"; } } if (this.timePickTo.Value != null) { var timeTo = this.timePickTo.Value; timeTo = timeTo.AddHours(-this.timePickTo.Value.Hour).AddMinutes(-this.timePickTo.Value.Minute).AddSeconds(-this.timePickTo.Value.Second); timeTo = timeTo.AddHours(23).AddMinutes(59).AddSeconds(59); if (this.cmbTime.Text == "录入时间") { command += " and convert(datetime,CreateTime) <='" + timeTo.ToString("yyyy-MM-dd HH:mm:ss") + "'"; } else if (this.cmbTime.Text == "处理时间") { command += " and convert(datetime,DealTime) <='" + timeTo.ToString("yyyy-MM-dd HH:mm:ss") + "'"; } else if (this.cmbTime.Text == "完结时间") { command += " and convert(datetime,FinishTime) <='" + timeTo.ToString("yyyy-MM-dd HH:mm:ss") + "'"; } //command += " and convert(datetime,CreateTime) <='" + timeTo.ToString("yyyy-MM-dd HH:mm:ss") + "'"; } DataTable dt = conn.GetDataTableBySql(command); if (dt.Rows.Count > 0) { int seq = 1; for (int i = 0; i < dt.Rows.Count; i++) { ExpressReceiveEntry entry = new ExpressReceiveEntry(); entry.SeqNum = seq; entry.ID = int.Parse(dt.Rows[i]["ID"].ToString()); entry.Status = dt.Rows[i]["Status"].ToString(); entry.ExpressNo = dt.Rows[i]["ExpressNo"].ToString(); entry.ExpressCompany = dt.Rows[i]["ExpressCompany"].ToString(); entry.BuyAdress = dt.Rows[i]["BuyAdress"].ToString(); entry.Resion = dt.Rows[i]["Resion"].ToString(); entry.CreateUser = dt.Rows[i]["CreateUser"].ToString(); entry.DealUser = dt.Rows[i]["DealUser"].ToString(); entry.Remark = dt.Rows[i]["Remark"].ToString(); entry.Remark2 = dt.Rows[i]["Remark2"].ToString(); entry.Remark3 = dt.Rows[i]["Remark3"].ToString(); entry.Remark4 = dt.Rows[i]["Remark4"].ToString(); entry.Result = dt.Rows[i]["Result"].ToString(); if (!string.IsNullOrEmpty(dt.Rows[i]["DealTime"].ToString())) { entry.DealTime = DateTime.Parse(dt.Rows[i]["DealTime"].ToString()); } if (!string.IsNullOrEmpty(dt.Rows[i]["CreateTime"].ToString())) { entry.CreateTime = DateTime.Parse(dt.Rows[i]["CreateTime"].ToString()); } if (!string.IsNullOrEmpty(dt.Rows[i]["FinishTime"].ToString())) { entry.FinishTime = DateTime.Parse(dt.Rows[i]["FinishTime"].ToString()); } seq++; ResultList.Add(entry); } //处理已超时 command = "select * from ResionSet"; dt = conn.GetDataTableBySql(command); if (dt.Rows.Count > 0) { List <ResionEntry> resionList = new List <ResionEntry>(); for (int i = 0; i < dt.Rows.Count; i++) { ResionEntry entry = new ResionEntry(); entry.Days = int.Parse(dt.Rows[i]["Days"].ToString()); entry.Resion = dt.Rows[i]["Resion"].ToString(); resionList.Add(entry); } foreach (var item in ResultList.Where(v => v.Status == "已处理" || v.Status == "未处理").ToList()) { var resionEntry = resionList.Where(v => v.Resion == item.Resion).FirstOrDefault(); if (resionEntry != null) { var time = resionEntry.Days * 24; TimeSpan?totalTime = DateTime.Now - item.CreateTime; if (totalTime.HasValue && totalTime.Value.TotalHours > time) { command = " update ExpressReceive set Status='已超时' where id='" + item.ID + "'"; string message = conn.ExecuteSql(command); item.Status = "已超时"; //if (!string.IsNullOrWhiteSpace(message)) // MessageBox.Show("序号:" + item.SeqNum + " 处理失败" + "失败原因:" + message); } } } } } this.dgShow.DataSource = null; this.dgShow.DataSource = ResultList; }