private void BeginSearch() { try { string txtFrom = dateFrom.SelectedDate.ToString("yyyy-MM-dd"); string txtTo = DateTo.SelectedDate.AddDays(1).ToString("yyyy-MM-dd"); if (dateFrom.SelectedDate.Year == 9999) { //errlable.Text = "开始时间日期格式错误"; dateFrom.Focus(); return; } if (dateFrom.SelectedDate.Year == 9999) { //errlable.Text = "截止时间日期格式错误"; DateTo.Focus(); return; } if (dateFrom.SelectedDate > DateTime.Today) { dateFrom.SelectedDate = DateTime.Today; return; } if (DateTo.SelectedDate > DateTime.Today) { DateTo.SelectedDate = DateTime.Today; DateTo.Focus(); return; } if (dateFrom.SelectedDate > DateTo.SelectedDate) { errlable.Text = "开始时间不能大于截止时间"; dateFrom.Focus(); return; } FullQuery(txtFrom, txtTo); CaculatePageCount(); GridView1.PagerSettings.LastPageText = ViewState["pageCount"].ToString(); BindGrid(); } catch { errlable.Text = ""; } }
private void startQuery() { try { string txtFrom = dateFrom.SelectedDate.ToString("yyyy-MM-dd"); string txtTo = DateTo.SelectedDate.ToString("yyyy-MM-dd");//.AddDays(1) if (dateFrom.SelectedDate.Year == 9999) { dateFrom.Focus(); return; } if (dateFrom.SelectedDate.Year == 9999) { DateTo.Focus(); return; } if (dateFrom.SelectedDate > DateTime.Today) { dateFrom.SelectedDate = DateTime.Today; return; } if (DateTo.SelectedDate > DateTime.Today) { DateTo.SelectedDate = DateTime.Today; DateTo.Focus(); return; } if (dateFrom.SelectedDate > DateTo.SelectedDate) { errlable.Text = "开始时间不能大于截止时间"; dateFrom.Focus(); return; } GetStudentUpdate(txtFrom, txtTo); CaculatePageCount(); GridView2.PagerSettings.LastPageText = ViewState["pageCount"].ToString(); BindGrid2(); } catch (Exception ex) { errlable.Text = ex.ToString(); } }
private void SaveLeave_Click(object sender, EventArgs e) { string query = ""; int TypeKey = ((KeyValuePair <int, string>)LeaveaTypeCombo.SelectedItem).Key; String TypeValue = ((KeyValuePair <int, string>)LeaveaTypeCombo.SelectedItem).Value; if (StaffID.Text.Trim() == "") { MessageBox.Show("Please Enter Staff ID"); StaffID.Focus(); return; } if (TypeKey < 1) { MessageBox.Show("Please Enter Leave Type"); LeaveaTypeCombo.Focus(); return; } if (DateFrom.Text == "") { MessageBox.Show("Please Enter Date From"); DateFrom.Focus(); return; } if (DateTo.Text.Trim() == "") { MessageBox.Show("Please Enter Date To"); DateTo.Focus(); return; } if (TotalLeave.Text.Trim() == "") { TotalLeave.Focus(); return; } else { if (!IsValid(TypeKey, TypeValue, Convert.ToInt32(TotalLeave.Text))) { MessageBox.Show("You can not apply for more than ur assigned leave!!!"); return; } } try { if (hiddenText.Text == "") { query = "INSERT INTO LeaveApply_Info(StaffID,Type,Datefrom,DateTo,Total) VALUES(" + Convert.ToInt32(StaffID.Text) + ", '" + TypeValue + "', '" + DateFrom.Value.ToString("yyyy/MM/dd") + "', '" + DateTo.Value.ToString("yyyy/MM/dd") + "', '" + TotalLeave.Text + "' )"; } else { query = "UPDATE LeaveApply_Info SET Type = '" + TypeValue + "', Datefrom= '" + DateFrom.Value.ToString("yyyy/MM/dd") + "',DateTo = '" + DateTo.Value.ToString("yyyy/MM/dd") + "', Total = '" + TotalLeave.Text + "' WHERE Id = " + Convert.ToInt32(hiddenText.Text); } if (DbAccess.ExecuteToDB(query)) { if (hiddenText.Text == "") { MessageBox.Show("Saved Successfully!!!"); } else { MessageBox.Show("Updated Successfully!!!"); } } else { MessageBox.Show("Failed To Save!!!"); } } catch (Exception ex) { MessageBox.Show("Connection Error!!!"); } finally { Reset(); } }