private void btn_save_Click(object sender, EventArgs e) { if (this.txt_client_code.Text == string.Empty || this.cbo_customer_location.Text == string.Empty || this.cbo_working_shift.Text == string.Empty) { MessageBox.Show("All values shaded red are required", "Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (!this.chk_absent.Checked) { Guard_deployment.Update_guard_deployment_record("update_guard_deployment_record", this.lbl_record_guid.Text, this.txt_client_code.Text, this.cbo_customer_location.Text, this.txt_fire_arm_serial.Text, (this.txt_ammunition_count.Text != string.Empty ? Convert.ToInt32(this.txt_ammunition_count.Text) : 0), this.cbo_working_shift.Text, (this.chk_leave.Checked ? true : false)); MessageBox.Show(string.Concat("Updated deployment record for ", this.lbl_name.Text, " successfully"), "Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { System.Windows.Forms.DialogResult dialogResult = MessageBox.Show(string.Concat("Marking", this.lbl_name.Text, " as absent will delete this record from the deployment list for this date.sure to proceed?"), "Deploy guards", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { Guard_deployment.delete_guard_marked_as_absent_from_deployment_list_per_date("delete_guard_marked_as_absent_from_deployment_list_per_date", this.lbl_record_guid.Text); return; } if (dialogResult == System.Windows.Forms.DialogResult.No) { base.Visible = true; return; } } }
private void btnsave_Click(object sender, EventArgs e) { if (txt_public_holiday_name.Text == String.Empty) { MessageBox.Show("Missing public holiday name", "Public Holidays", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (txt_public_holiday_name.Text.Length < 2) { MessageBox.Show("Type in a valid public holiday name", "Public Holidays", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (dt_public_holiday_date.Value.Date < dt_start_date.Value.Date || dt_public_holiday_date.Value.Date > dt_end_date.Value.Date) { MessageBox.Show("Public holiday must be in range of current deployment period", "Public Holidays", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (txt_record_guid.Text != String.Empty) { //update public holiday Guard_deployment.update_public_holiday_details("update_public_holiday_details", txt_record_guid.Text, txt_public_holiday_name.Text, dt_public_holiday_date.Value.Date); MessageBox.Show("Successfully updated public holiday", "Public Holidays", MessageBoxButtons.OK, MessageBoxIcon.Information); get_list_of_public_holidays(); } else { Guard_deployment.save_new_public_holiday("save_new_public_holiday", Convert.ToInt32(SystemConst._active_deployment_id), txt_public_holiday_name.Text, dt_public_holiday_date.Value.Date); MessageBox.Show("Successfully saved public holiday", "Public Holidays", MessageBoxButtons.OK, MessageBoxIcon.Information); get_list_of_public_holidays(); } }
private void cbo_deploy_period_SelectionChangeCommitted(object sender, EventArgs e) { if (cbo_deploy_period.Text != string.Empty) { Guard_deployment.select_deployment_date_by_deploy_id("select_deployment_date_by_deploy_id", Convert.ToInt32(cbo_deploy_period.SelectedValue.ToString())); } }
//return guards for batch deploy.... protected void get_list_of_guards_for_batch_deploy() { DataTable dt = Guard_deployment.select_list_of_guards_by_branch_and_date_for_batch_deployment("select_list_of_guards_by_branch_and_date_for_batch_deployment", cbo_branch.Text); if (dt.Rows.Count > 0) { //set value of deployment date DataRow dtRow = dt.Rows[0]; dt_deployment_date.Value = Convert.ToDateTime(dtRow["next_deploy_date"]); gdv_deployment_summary.DataSource = dt; gdv_deployment_summary.Columns["deploy_type"].Visible = false; gdv_deployment_summary.Columns["branch_name"].Visible = false; gdv_deployment_summary.Columns["guard_auto_id"].Visible = false; gdv_deployment_summary.Columns["firearm_serial"].Visible = false; gdv_deployment_summary.Columns["number_of_ammunitions"].Visible = false; gdv_deployment_summary.Columns["is_leave_day_for_guard"].Visible = false; gdv_deployment_summary.Columns["is_public_holiday"].Visible = false; gdv_deployment_summary.Columns["deploy_date"].Visible = false; gdv_deployment_summary.Columns["is_weekend"].Visible = false; gdv_deployment_summary.Columns["guard_name"].HeaderText = "Guard"; gdv_deployment_summary.Columns["guard_number"].HeaderText = "Guard"; gdv_deployment_summary.Columns["next_deploy_date"].HeaderText = "Day"; gdv_deployment_summary.Columns["client_name"].HeaderText = "Client"; gdv_deployment_summary.Columns["client_code"].HeaderText = "Client Code"; gdv_deployment_summary.Columns["client_location"].HeaderText = "Location"; gdv_deployment_summary.Columns["shift_type"].HeaderText = "Shift"; gdv_deployment_summary.Columns["guard_name"].Width = 250; gdv_deployment_summary.RowsDefaultCellStyle.BackColor = Color.LightGray; gdv_deployment_summary.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; // Set the row and column header styles. gdv_deployment_summary.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; gdv_deployment_summary.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; gdv_deployment_summary.RowHeadersDefaultCellStyle.BackColor = Color.Black; // Set the selection background color for all the cells. gdv_deployment_summary.DefaultCellStyle.SelectionBackColor = Color.DeepSkyBlue; gdv_deployment_summary.DefaultCellStyle.SelectionForeColor = Color.Black; foreach (DataGridViewColumn c in gdv_deployment_summary.Columns) { c.DefaultCellStyle.Font = new Font("Arial", 11F, GraphicsUnit.Pixel); } //set the background color of the header row gdv_deployment_summary.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; gdv_deployment_summary.EnableHeadersVisualStyles = false; //set batch save status as not saved chk_save_status.Checked = false; } else { gdv_deployment_summary.DataSource = dt; } }
protected void return_deployment_periods() { DataTable dt = Guard_deployment.Return_list_of_deployment_periods("return_list_of_deployment_periods"); if (dt.Rows.Count > 0) { this.gdv_deployment_periods.DataSource = dt; this.gdv_deployment_periods.Columns["deploy_id"].Visible = false; this.gdv_deployment_periods.Columns["deploy_start_date"].HeaderText = "Deployment start date"; this.gdv_deployment_periods.Columns["deploy_end_date"].HeaderText = "Deployment end date"; this.gdv_deployment_periods.Columns["created_by"].HeaderText = "Created by"; this.gdv_deployment_periods.Columns["active_deployment"].Visible = false; this.gdv_deployment_periods.RowsDefaultCellStyle.BackColor = Color.LightGray; this.gdv_deployment_periods.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; this.gdv_deployment_periods.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; this.gdv_deployment_periods.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_deployment_periods.RowHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_deployment_periods.DefaultCellStyle.SelectionBackColor = Color.Cyan; this.gdv_deployment_periods.DefaultCellStyle.SelectionForeColor = Color.Black; foreach (DataGridViewColumn c in this.gdv_deployment_periods.Columns) { c.DefaultCellStyle.Font = new System.Drawing.Font("Arial", 11f, GraphicsUnit.Pixel); } this.gdv_deployment_periods.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; this.gdv_deployment_periods.EnableHeadersVisualStyles = false; } }
private void btn_save_Click(object sender, EventArgs e) { if (txt_client_code.Text == String.Empty || cbo_customer_location.Text == String.Empty || cbo_working_shift.Text == String.Empty) { MessageBox.Show("All values shaded red are required", "Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (chk_absent.Checked == true) { DialogResult dialogResult = MessageBox.Show("Marking" + lbl_name.Text + " as absent will delete this record from the deployment list for this date.sure to proceed?", "Deploy guards", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { Guard_deployment.delete_guard_marked_as_absent_from_deployment_list_per_date("delete_guard_marked_as_absent_from_deployment_list_per_date", lbl_record_guid.Text); } else if (dialogResult == DialogResult.No) { this.Visible = true; } } else { Guard_deployment.Update_guard_deployment_record("update_guard_deployment_record", lbl_record_guid.Text, txt_client_code.Text, cbo_customer_location.Text, txt_fire_arm_serial.Text, txt_ammunition_count.Text != String.Empty ? Convert.ToInt32(txt_ammunition_count.Text) : 0, cbo_working_shift.Text, chk_leave.Checked == true ? true : false); MessageBox.Show("Updated deployment record for " + lbl_name.Text + " successfully", "Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
protected void get_list_of_public_holidays() { DataTable dt = Guard_deployment.return_list_of_public_holidays("return_list_of_public_holidays"); if (dt.Rows.Count > 0) { this.gdv_public_holidays.DataSource = dt; this.gdv_public_holidays.Columns["record_guid"].Visible = false; this.gdv_public_holidays.Columns["deployment_period_id"].Visible = false; this.gdv_public_holidays.Columns["public_holiday_name"].HeaderText = "Public Holiday Name"; this.gdv_public_holidays.Columns["public_holiday_date"].HeaderText = "Public Holiday Date"; this.gdv_public_holidays.RowsDefaultCellStyle.BackColor = Color.LightGray; this.gdv_public_holidays.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; this.gdv_public_holidays.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; this.gdv_public_holidays.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_public_holidays.RowHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_public_holidays.DefaultCellStyle.SelectionBackColor = Color.Cyan; this.gdv_public_holidays.DefaultCellStyle.SelectionForeColor = Color.Black; foreach (DataGridViewColumn c in this.gdv_public_holidays.Columns) { c.DefaultCellStyle.Font = new System.Drawing.Font("Arial", 11f, GraphicsUnit.Pixel); } this.gdv_public_holidays.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; this.gdv_public_holidays.EnableHeadersVisualStyles = false; } }
private void btnsave_Click(object sender, EventArgs e) { if (this.txt_public_holiday_name.Text == string.Empty) { MessageBox.Show("Missing public holiday name", "Public Holidays", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (this.txt_public_holiday_name.Text.Length < 2) { MessageBox.Show("Type in a valid public holiday name", "Public Holidays", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (this.dt_public_holiday_date.Value.Date < this.dt_start_date.Value.Date || this.dt_public_holiday_date.Value.Date > this.dt_end_date.Value.Date) { MessageBox.Show("Public holiday must be in range of current deployment period", "Public Holidays", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (this.txt_record_guid.Text == string.Empty) { int num = Convert.ToInt32(SystemConst._active_deployment_id); string text = this.txt_public_holiday_name.Text; DateTime value = this.dt_public_holiday_date.Value; Guard_deployment.save_new_public_holiday("save_new_public_holiday", num, text, value.Date); MessageBox.Show("Successfully saved public holiday", "Public Holidays", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.get_list_of_public_holidays(); return; } string str = this.txt_record_guid.Text; string text1 = this.txt_public_holiday_name.Text; DateTime dateTime = this.dt_public_holiday_date.Value; Guard_deployment.update_public_holiday_details("update_public_holiday_details", str, text1, dateTime.Date); MessageBox.Show("Successfully updated public holiday", "Public Holidays", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.get_list_of_public_holidays(); }
protected void Save_or_Update_batch_deployment() { if (this.gdv_deployment_summary.Rows.Count > 0) { System.Windows.Forms.DialogResult dialogResult = MessageBox.Show("This might take a while.Save Batch Deploy?", " Batch Deploy", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { for (int i = 0; i < this.gdv_deployment_summary.Rows.Count; i++) { string guard_number = this.gdv_deployment_summary.Rows[i].Cells[1].Value.ToString(); string guard_name = this.gdv_deployment_summary.Rows[i].Cells[0].Value.ToString(); DateTime deployment_date = Convert.ToDateTime(this.gdv_deployment_summary.Rows[i].Cells[2].Value); string deploy_type = this.gdv_deployment_summary.Rows[i].Cells[8].Value.ToString(); string branch_name = this.gdv_deployment_summary.Rows[i].Cells[9].Value.ToString(); string client_code = this.gdv_deployment_summary.Rows[i].Cells[5].Value.ToString(); string client_location = this.gdv_deployment_summary.Rows[i].Cells[6].Value.ToString(); string fire_arm_serial = this.gdv_deployment_summary.Rows[i].Cells[11].Value.ToString(); int ammunition_count = Convert.ToInt32(this.gdv_deployment_summary.Rows[i].Cells[12].Value.ToString()); string shift_type = this.gdv_deployment_summary.Rows[i].Cells[7].Value.ToString(); bool is_leave_day_for_guard = Convert.ToBoolean(this.gdv_deployment_summary.Rows[i].Cells[13].Value); DateTime date = this.dt_start_date.Value.Date; DateTime value = this.dt_end_date.Value; Guard_deployment.Save_new_deployment_record("save_new_deployment_record", date, value.Date, SystemConst._username, guard_number, deployment_date, deploy_type, branch_name, client_code, client_location, guard_name, fire_arm_serial, ammunition_count, shift_type, is_leave_day_for_guard, frm_guard_deployment_summary_batch._is_public_holiday, frm_guard_deployment_summary_batch._is_weekend, SystemConst._user_id); Guard_deployment.Save_deployment_schedule(deployment_date, Convert.ToInt32(SystemConst._active_deployment_id), guard_number); } } else if (dialogResult == System.Windows.Forms.DialogResult.No) { base.Visible = true; } MessageBox.Show(string.Concat("Successfully deployed all guards in ", this.cbo_branch.Text, " for this date"), "Batch Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.chk_save_status.Checked = true; } }
protected void LoadMycurrentDeployPeriod() { DataTable _dt = Guard_deployment.select_my_active_deployment_period("select_my_active_deployment_period", SystemConst._user_id); if (_dt.Rows.Count > 0) { this.gdv_current_deployment_period.DataSource = _dt; this.gdv_current_deployment_period.Columns["deploy_id"].Visible = false; this.gdv_current_deployment_period.Columns["deploy_start_date"].HeaderText = "Deployment start date"; this.gdv_current_deployment_period.Columns["deploy_end_date"].HeaderText = "Deployment end date"; this.gdv_current_deployment_period.Columns["user_id"].Visible = false; this.gdv_current_deployment_period.RowsDefaultCellStyle.BackColor = Color.LightGray; this.gdv_current_deployment_period.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; this.gdv_current_deployment_period.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; this.gdv_current_deployment_period.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_current_deployment_period.RowHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_current_deployment_period.DefaultCellStyle.SelectionBackColor = Color.Cyan; this.gdv_current_deployment_period.DefaultCellStyle.SelectionForeColor = Color.Black; foreach (DataGridViewColumn c in this.gdv_current_deployment_period.Columns) { c.DefaultCellStyle.Font = new System.Drawing.Font("Arial", 11f, GraphicsUnit.Pixel); } this.gdv_current_deployment_period.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; this.gdv_current_deployment_period.EnableHeadersVisualStyles = false; } }
protected void Get_list_of_guards_for_selected_deploy_date() { if (!this.dt_deployment_date.Checked) { MessageBox.Show("Select a deployment date", "Batch Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } string text = this.cbo_branch.Text; DateTime value = this.dt_deployment_date.Value; DataTable dt = Guard_deployment.select_list_of_guards_by_branch_and_date_for_selected_date("select_list_of_guards_by_branch_and_date_for_selected_date", text, value.Date); if (dt.Rows.Count <= 0) { this.gdv_deployment_summary.DataSource = dt; return; } DataRow item = dt.Rows[0]; this.gdv_deployment_summary.DataSource = dt; this.gdv_deployment_summary.Columns["deploy_type"].Visible = false; this.gdv_deployment_summary.Columns["branch_name"].Visible = false; this.gdv_deployment_summary.Columns["guard_auto_id"].Visible = false; this.gdv_deployment_summary.Columns["firearm_serial"].Visible = false; this.gdv_deployment_summary.Columns["number_of_ammunitions"].Visible = false; this.gdv_deployment_summary.Columns["is_leave_day_for_guard"].Visible = false; this.gdv_deployment_summary.Columns["is_public_holiday"].Visible = false; this.gdv_deployment_summary.Columns["record_guid"].Visible = false; this.gdv_deployment_summary.Columns["is_weekend"].Visible = false; this.gdv_deployment_summary.Columns["guard_name"].HeaderText = "Guard"; this.gdv_deployment_summary.Columns["guard_number"].HeaderText = "Guard Number"; this.gdv_deployment_summary.Columns["next_deploy_date"].HeaderText = "Day"; this.gdv_deployment_summary.Columns["client_name"].HeaderText = "Client"; this.gdv_deployment_summary.Columns["client_code"].HeaderText = "Client Code"; this.gdv_deployment_summary.Columns["client_location"].HeaderText = "Location"; this.gdv_deployment_summary.Columns["shift_type"].HeaderText = "Shift"; this.gdv_deployment_summary.Columns["guard_name"].Width = 250; this.gdv_deployment_summary.RowsDefaultCellStyle.BackColor = Color.LightGray; this.gdv_deployment_summary.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; this.gdv_deployment_summary.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; this.gdv_deployment_summary.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_deployment_summary.RowHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_deployment_summary.DefaultCellStyle.SelectionBackColor = Color.DeepSkyBlue; this.gdv_deployment_summary.DefaultCellStyle.SelectionForeColor = Color.Black; foreach (DataGridViewColumn c in this.gdv_deployment_summary.Columns) { c.DefaultCellStyle.Font = new System.Drawing.Font("Arial", 11f, GraphicsUnit.Pixel); } this.gdv_deployment_summary.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; this.gdv_deployment_summary.EnableHeadersVisualStyles = false; this.chk_save_status.Checked = true; lblCount.Text = dt.Rows.Count.ToString() + " Guards Loaded"; }
//set deployment periods protected void Set_current_deployment_periods() { DataTable dt = Guard_deployment.Select_active_deployment_period("select_active_deployment_period"); if (dt.Rows.Count > 0) { DataRow dtRow = dt.Rows[0]; SystemConst._active_deployment_id = Convert.ToInt32(dtRow["deploy_id"].ToString()).ToString(); SystemConst._deployment_start_date = Convert.ToDateTime(dtRow["deploy_start_date"]); SystemConst._deployment_end_date = Convert.ToDateTime(dtRow["deploy_end_date"]); } }
private void btndelete_Click(object sender, EventArgs e) { System.Windows.Forms.DialogResult dialogResult = MessageBox.Show("Are you sure to delete this public holiday", "Delete Public holiday", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dialogResult != System.Windows.Forms.DialogResult.Yes) { if (dialogResult == System.Windows.Forms.DialogResult.No) { base.Visible = true; } return; } Guard_deployment.delete_public_holiday("delete_public_holiday", this.txt_record_guid.Text); this.get_list_of_public_holidays(); }
private void btndelete_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure to delete this public holiday", "Delete Public holiday", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { Guard_deployment.delete_public_holiday("delete_public_holiday", txt_record_guid.Text); get_list_of_public_holidays(); } else if (dialogResult == DialogResult.No) { this.Visible = true; } }
protected void Get_guard_shift_types() { DataTable dt = Guard_deployment.Return_guard_shift_types("return_guard_shift_types"); if (dt.Rows.Count > 0) { DataRow dtRow = dt.NewRow(); dtRow["shift_name"] = string.Empty; dtRow["shift_id"] = -1; dt.Rows.InsertAt(dtRow, 0); this.cbo_working_shift.DataSource = dt; this.cbo_working_shift.DisplayMember = "shift_name"; this.cbo_working_shift.ValueMember = "shift_id"; } }
protected void return_deployment_periods() { DataTable dt = Guard_deployment.Return_list_of_deployment_periods("return_list_of_deployment_periods_for_accounts_reports_selector"); if (dt.Rows.Count > 0) { DataRow dtRow = dt.NewRow(); dtRow["deploy_id"] = -1; dtRow["period"] = string.Empty; dt.Rows.InsertAt(dtRow, 0); this.cbo_deploy_period.DisplayMember = "period"; this.cbo_deploy_period.ValueMember = "deploy_id"; this.cbo_deploy_period.DataSource = dt; } }
protected void save() { if (lbl_guid.Text == "lbl_guid") { MessageBox.Show("Please select a deployment period from the list", "Guard Profiler", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Guard_deployment.save_update_my_current_deployment_period("save_my_current_deploy_period", Convert.ToInt32(lbl_guid.Text), SystemConst._user_id); MessageBox.Show("Successfully updated your current deployment period", "Guard Profiler", MessageBoxButtons.OK, MessageBoxIcon.Information); return_deployment_periods(); LoadMycurrentDeployPeriod(); Set_current_deployment_periods(); } }
protected void get_list_of_guards_for_batch_deploy() { DataTable dt = Guard_deployment.select_list_of_guards_by_branch_and_date_for_batch_deployment("select_list_of_guards_by_branch_and_date_for_batch_deployment", this.cbo_branch.Text, SystemConst._user_id); if (dt.Rows.Count <= 0) { this.gdv_deployment_summary.DataSource = dt; return; } DataRow dtRow = dt.Rows[0]; this.dt_deployment_date.Value = Convert.ToDateTime(dtRow["next_deploy_date"]); this.gdv_deployment_summary.DataSource = dt; this.gdv_deployment_summary.Columns["deploy_type"].Visible = false; this.gdv_deployment_summary.Columns["branch_name"].Visible = false; this.gdv_deployment_summary.Columns["guard_auto_id"].Visible = false; this.gdv_deployment_summary.Columns["firearm_serial"].Visible = false; this.gdv_deployment_summary.Columns["number_of_ammunitions"].Visible = false; this.gdv_deployment_summary.Columns["is_leave_day_for_guard"].Visible = false; this.gdv_deployment_summary.Columns["is_public_holiday"].Visible = false; this.gdv_deployment_summary.Columns["deploy_date"].Visible = false; this.gdv_deployment_summary.Columns["is_weekend"].Visible = false; this.gdv_deployment_summary.Columns["guard_name"].HeaderText = "Guard"; this.gdv_deployment_summary.Columns["guard_number"].HeaderText = "Guard Number"; this.gdv_deployment_summary.Columns["next_deploy_date"].HeaderText = "Day"; this.gdv_deployment_summary.Columns["client_name"].HeaderText = "Client"; this.gdv_deployment_summary.Columns["client_code"].HeaderText = "Client Code"; this.gdv_deployment_summary.Columns["client_location"].HeaderText = "Location"; this.gdv_deployment_summary.Columns["shift_type"].HeaderText = "Shift"; this.gdv_deployment_summary.Columns["guard_name"].Width = 250; this.gdv_deployment_summary.RowsDefaultCellStyle.BackColor = Color.LightGray; this.gdv_deployment_summary.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; this.gdv_deployment_summary.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; this.gdv_deployment_summary.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_deployment_summary.RowHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_deployment_summary.DefaultCellStyle.SelectionBackColor = Color.DeepSkyBlue; this.gdv_deployment_summary.DefaultCellStyle.SelectionForeColor = Color.Black; foreach (DataGridViewColumn c in this.gdv_deployment_summary.Columns) { c.DefaultCellStyle.Font = new System.Drawing.Font("Arial", 11f, GraphicsUnit.Pixel); } this.gdv_deployment_summary.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; this.gdv_deployment_summary.EnableHeadersVisualStyles = false; this.chk_save_status.Checked = false; lblCount.Text = dt.Rows.Count.ToString() + " Guards Loaded"; }
protected void Set_current_deployment_periods() { DataTable dt = Guard_deployment.select_my_active_deployment_period("select_my_active_deployment_period", SystemConst._user_id); if (dt.Rows.Count > 0) { DataRow dtRow = dt.Rows[0]; int num = Convert.ToInt32(dtRow["deploy_id"].ToString()); SystemConst._active_deployment_id = num.ToString(); SystemConst._deployment_start_date = Convert.ToDateTime(dtRow["deploy_start_date"]); SystemConst._deployment_end_date = Convert.ToDateTime(dtRow["deploy_end_date"]); } else { SystemConst._active_deployment_id = string.Empty; } }
private void dt_deployment_date_ValueChanged(object sender, EventArgs e) { if (this.dt_deployment_date.Value.Date.DayOfWeek == DayOfWeek.Saturday || this.dt_deployment_date.Value.Date.DayOfWeek == DayOfWeek.Sunday) { frm_guard_deployment_summary_batch._is_weekend = true; } else { frm_guard_deployment_summary_batch._is_weekend = false; } if (Guard_deployment.check_if_deployment_date_is_public_holiday("check_if_deployment_date_is_public_holiday", this.dt_deployment_date.Value.Date) > 0) { frm_guard_deployment_summary_batch._is_public_holiday = true; return; } frm_guard_deployment_summary_batch._is_public_holiday = false; }
protected void Save_guard_deployment_record() { if (dt_start_date.Checked == false || dt_end_date.Checked == false || dt_deployment_date.Checked == false || cbo_deploy_type.Text == String.Empty || cbo_branch.Text == String.Empty || cbo_customer_name.Text == String.Empty || cbo_customer_location.Text == String.Empty || cbo_guard_name.Text == String.Empty || cbo_working_shift.Text == String.Empty) { MessageBox.Show("Fill in all required values", "Client Locations", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { Guard_deployment.Save_new_deployment_record("save_new_deployment_record", dt_start_date.Value.Date, dt_end_date.Value.Date, SystemConst._username, txt_guard_number.Text, dt_deployment_date.Value.Date, cbo_deploy_type.Text, cbo_branch.Text, txt_client_code.Text, cbo_customer_location.Text, cbo_guard_name.Text, txt_fire_arm_serial.Text, txt_ammunition_count.Text != String.Empty ? Convert.ToInt32(txt_ammunition_count.Text) : 0, cbo_working_shift.Text, chk_leave.Checked == true ? true : false, chk_public_holiday.Checked == true ? true : false, chk_weekend.Checked == true?true:false); MessageBox.Show("Successfully deployed guard for this date", "Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Information); Return_list_of_deployments_by_deploy_id(); } }
private void btn_save_Click(object sender, EventArgs e) { if (gdv_guards.Rows.Count > 0) { DialogResult dialogResult = MessageBox.Show("This might take a while.Proceed?", " Message Centre", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { for (int i = 0; i < gdv_guards.Rows.Count; i++) { int guard_auto_id = Convert.ToInt32(gdv_guards.Rows[i].Cells[1].Value.ToString()); DateTime pay_month = dt_start_date.Value.Date; string guard_number = gdv_guards.Rows[i].Cells[2].Value.ToString(); int days_worked = gdv_guards.Rows[i].Cells[4].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[4].Value.ToString()) : 0; int over_time_days_worked = gdv_guards.Rows[i].Cells[5].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[5].Value.ToString()) : 0; int days_absent = gdv_guards.Rows[i].Cells[7].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[7].Value.ToString()) : 0; float total_advance_in_month = gdv_guards.Rows[i].Cells[8].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[8].Value.ToString()) : 0; float total_arrears_in_month = gdv_guards.Rows[i].Cells[9].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[9].Value.ToString()) : 0; float special_cash_additions = gdv_guards.Rows[i].Cells[10].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[10].Value.ToString()) : 0; float residential_cost = gdv_guards.Rows[i].Cells[11].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[11].Value.ToString()) : 0; float uniform_costs = gdv_guards.Rows[i].Cells[12].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[12].Value.ToString()) : 0; float local_service_tax_cost = gdv_guards.Rows[i].Cells[13].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[13].Value.ToString()) : 0; float other_penalties_cost = gdv_guards.Rows[i].Cells[14].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[14].Value.ToString()) : 0; float other_refunds = gdv_guards.Rows[i].Cells[15].Value.ToString() != String.Empty ? Convert.ToInt32(gdv_guards.Rows[i].Cells[15].Value.ToString()) : 0; //save row records Guard_deployment.Save_update_guard_additional_deployment_data("save_update_guard_additional_deployment_data", guard_number, pay_month, guard_auto_id, days_worked, over_time_days_worked, days_absent, total_advance_in_month, total_arrears_in_month, special_cash_additions, residential_cost, uniform_costs, local_service_tax_cost, other_penalties_cost, other_refunds, Convert.ToInt32(SystemConst._active_deployment_id)); } MessageBox.Show("All records saved successfully", "Message Centre", MessageBoxButtons.OK, MessageBoxIcon.Information); btn_search_Click(btn_search, null); } else if (dialogResult == DialogResult.No) { this.Visible = true; } } else { MessageBox.Show("No records available to save", "Message Centre", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
protected void Return_list_of_deployments_by_deploy_id() { DataTable dt = Guard_deployment.Return_list_of_deployments_by_deploy_id("return_list_of_deployments_by_deploy_id"); if (dt.Rows.Count > 0) { gdv_deployment_summary.DataSource = dt; gdv_deployment_summary.Columns["deploy_details_id"].Visible = false; gdv_deployment_summary.Columns["guard_name"].HeaderText = "Guard"; gdv_deployment_summary.Columns["branch_name"].HeaderText = "Branch"; gdv_deployment_summary.Columns["deploy_date"].HeaderText = "Date"; gdv_deployment_summary.Columns["deploy_type"].HeaderText = "D.Type"; gdv_deployment_summary.Columns["shift_type"].HeaderText = "Shift"; gdv_deployment_summary.Columns["deploy_date"].Width = 40; gdv_deployment_summary.Columns["guard_name"].Width = 110; gdv_deployment_summary.Columns["deploy_type"].Width = 50; gdv_deployment_summary.RowsDefaultCellStyle.BackColor = Color.LightGray; gdv_deployment_summary.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; // Set the row and column header styles. gdv_deployment_summary.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; gdv_deployment_summary.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; gdv_deployment_summary.RowHeadersDefaultCellStyle.BackColor = Color.Black; // Set the selection background color for all the cells. gdv_deployment_summary.DefaultCellStyle.SelectionBackColor = Color.Brown; gdv_deployment_summary.DefaultCellStyle.SelectionForeColor = Color.Black; foreach (DataGridViewColumn c in gdv_deployment_summary.Columns) { c.DefaultCellStyle.Font = new Font("Arial", 11F, GraphicsUnit.Pixel); } //set the background color of the header row gdv_deployment_summary.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; gdv_deployment_summary.EnableHeadersVisualStyles = false; } }
private void dt_deployment_date_ValueChanged(object sender, EventArgs e) { //check if selected date is a weekend if (dt_deployment_date.Value.Date.DayOfWeek == DayOfWeek.Saturday || dt_deployment_date.Value.Date.DayOfWeek == DayOfWeek.Sunday) { _is_weekend = true; } else { _is_weekend = false; } //check if selected date is a public holiday if (Guard_deployment.check_if_deployment_date_is_public_holiday("check_if_deployment_date_is_public_holiday", dt_deployment_date.Value.Date) > 0) { _is_public_holiday = true; } else { _is_public_holiday = false; } }
protected void return_deployment_periods() { DataTable dt = Guard_deployment.Return_list_of_deployment_periods("return_list_of_deployment_periods"); if (dt.Rows.Count > 0) { gdv_deployment_periods.DataSource = dt; gdv_deployment_periods.Columns["deploy_id"].Visible = false; gdv_deployment_periods.Columns["deploy_start_date"].HeaderText = "Deployment start date"; gdv_deployment_periods.Columns["deploy_end_date"].HeaderText = "Deployment end date"; gdv_deployment_periods.Columns["created_by"].HeaderText = "Created by"; gdv_deployment_periods.Columns["active_deployment"].HeaderText = "Active Deployment"; gdv_deployment_periods.RowsDefaultCellStyle.BackColor = Color.LightGray; gdv_deployment_periods.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; // Set the row and column header styles. gdv_deployment_periods.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; gdv_deployment_periods.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; gdv_deployment_periods.RowHeadersDefaultCellStyle.BackColor = Color.Black; // Set the selection background color for all the cells. gdv_deployment_periods.DefaultCellStyle.SelectionBackColor = Color.Cyan; gdv_deployment_periods.DefaultCellStyle.SelectionForeColor = Color.Black; foreach (DataGridViewColumn c in gdv_deployment_periods.Columns) { c.DefaultCellStyle.Font = new Font("Arial", 11F, GraphicsUnit.Pixel); } //set the background color of the header row gdv_deployment_periods.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; gdv_deployment_periods.EnableHeadersVisualStyles = false; } }
protected void Save_or_Update_batch_deployment() { if (gdv_deployment_summary.Rows.Count > 0) { DialogResult dialogResult = MessageBox.Show("This might take a while.Save Batch Deploy?", " Batch Deploy", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { for (int i = 0; i < gdv_deployment_summary.Rows.Count; i++) { string guard_number = gdv_deployment_summary.Rows[i].Cells[1].Value.ToString(); string guard_name = gdv_deployment_summary.Rows[i].Cells[0].Value.ToString(); DateTime deployment_date = Convert.ToDateTime(gdv_deployment_summary.Rows[i].Cells[2].Value); string deploy_type = gdv_deployment_summary.Rows[i].Cells[8].Value.ToString(); string branch_name = gdv_deployment_summary.Rows[i].Cells[9].Value.ToString(); string client_code = gdv_deployment_summary.Rows[i].Cells[5].Value.ToString(); string client_location = gdv_deployment_summary.Rows[i].Cells[6].Value.ToString(); string fire_arm_serial = gdv_deployment_summary.Rows[i].Cells[11].Value.ToString(); int ammunition_count = Convert.ToInt32(gdv_deployment_summary.Rows[i].Cells[12].Value.ToString()); string shift_type = gdv_deployment_summary.Rows[i].Cells[7].Value.ToString(); bool is_leave_day_for_guard = Convert.ToBoolean(gdv_deployment_summary.Rows[i].Cells[13].Value); //call function to save this batch record Guard_deployment.Save_new_deployment_record("save_new_deployment_record", dt_start_date.Value.Date, dt_end_date.Value.Date, SystemConst._username, guard_number, deployment_date, deploy_type, branch_name, client_code, client_location, guard_name, fire_arm_serial, ammunition_count, shift_type, is_leave_day_for_guard, _is_public_holiday, _is_weekend); } } else if (dialogResult == DialogResult.No) { this.Visible = true; } MessageBox.Show("Successfully deployed all guards in " + cbo_branch.Text + " for this date", "Batch Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Information); chk_save_status.Checked = true; //Return_list_of_deployments_by_deploy_id(); } }
protected void get_list_of_public_holidays() { DataTable dt = Guard_deployment.return_list_of_public_holidays("return_list_of_public_holidays"); if (dt.Rows.Count > 0) { gdv_public_holidays.DataSource = dt; gdv_public_holidays.Columns["record_guid"].Visible = false; gdv_public_holidays.Columns["deployment_period_id"].Visible = false; gdv_public_holidays.Columns["public_holiday_name"].HeaderText = "Public Holiday Name"; gdv_public_holidays.Columns["public_holiday_date"].HeaderText = "Public Holiday Date"; gdv_public_holidays.RowsDefaultCellStyle.BackColor = Color.LightGray; gdv_public_holidays.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; // Set the row and column header styles. gdv_public_holidays.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; gdv_public_holidays.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; gdv_public_holidays.RowHeadersDefaultCellStyle.BackColor = Color.Black; // Set the selection background color for all the cells. gdv_public_holidays.DefaultCellStyle.SelectionBackColor = Color.Cyan; gdv_public_holidays.DefaultCellStyle.SelectionForeColor = Color.Black; foreach (DataGridViewColumn c in gdv_public_holidays.Columns) { c.DefaultCellStyle.Font = new Font("Arial", 11F, GraphicsUnit.Pixel); } //set the background color of the header row gdv_public_holidays.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; gdv_public_holidays.EnableHeadersVisualStyles = false; } }
//return guards for particular deploy date which was already saved protected void Get_list_of_guards_for_selected_deploy_date() { if (dt_deployment_date.Checked == false) { MessageBox.Show("Select a deployment date", "Batch Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { DataTable dt = Guard_deployment.select_list_of_guards_by_branch_and_date_for_selected_date("select_list_of_guards_by_branch_and_date_for_selected_date", cbo_branch.Text, dt_deployment_date.Value.Date); if (dt.Rows.Count > 0) { //set value of deployment date DataRow dtRow = dt.Rows[0]; gdv_deployment_summary.DataSource = dt; gdv_deployment_summary.Columns["deploy_type"].Visible = false; gdv_deployment_summary.Columns["branch_name"].Visible = false; gdv_deployment_summary.Columns["guard_auto_id"].Visible = false; gdv_deployment_summary.Columns["firearm_serial"].Visible = false; gdv_deployment_summary.Columns["number_of_ammunitions"].Visible = false; gdv_deployment_summary.Columns["is_leave_day_for_guard"].Visible = false; gdv_deployment_summary.Columns["is_public_holiday"].Visible = false; gdv_deployment_summary.Columns["record_guid"].Visible = false; gdv_deployment_summary.Columns["is_weekend"].Visible = false; gdv_deployment_summary.Columns["guard_name"].HeaderText = "Guard"; gdv_deployment_summary.Columns["guard_number"].HeaderText = "Guard"; gdv_deployment_summary.Columns["next_deploy_date"].HeaderText = "Day"; gdv_deployment_summary.Columns["client_name"].HeaderText = "Client"; gdv_deployment_summary.Columns["client_code"].HeaderText = "Client Code"; gdv_deployment_summary.Columns["client_location"].HeaderText = "Location"; gdv_deployment_summary.Columns["shift_type"].HeaderText = "Shift"; gdv_deployment_summary.Columns["guard_name"].Width = 250; gdv_deployment_summary.RowsDefaultCellStyle.BackColor = Color.LightGray; gdv_deployment_summary.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; // Set the row and column header styles. gdv_deployment_summary.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; gdv_deployment_summary.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; gdv_deployment_summary.RowHeadersDefaultCellStyle.BackColor = Color.Black; // Set the selection background color for all the cells. gdv_deployment_summary.DefaultCellStyle.SelectionBackColor = Color.DeepSkyBlue; gdv_deployment_summary.DefaultCellStyle.SelectionForeColor = Color.Black; foreach (DataGridViewColumn c in gdv_deployment_summary.Columns) { c.DefaultCellStyle.Font = new Font("Arial", 11F, GraphicsUnit.Pixel); } //set the background color of the header row gdv_deployment_summary.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; gdv_deployment_summary.EnableHeadersVisualStyles = false; //set this batch as saved already chk_save_status.Checked = true; } else { gdv_deployment_summary.DataSource = dt; } } }
protected void Get_guard_list() { DataTable dt = new DataTable(); if (this.cbo_branch.Text == string.Empty) { MessageBox.Show("Select a branch to search", "Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else if (SystemConst._user_department == "Accounts" && cbo_deploy_period.Text == string.Empty) { MessageBox.Show("Please select a payment period to proceed with search", "Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string text = this.cbo_branch.Text; string str = this.txt_guard_number.Text; DateTime date = this.dt_start_date.Value.Date; DateTime value = this.dt_end_date.Value; //dt = Guard_deployment.select_list_of_guards_for_additional_deployment_data_entry("select_list_of_guards_for_additional_deployment_data_entry", text, str, date, value.Date, SystemConst._user_id); dt = Guard_deployment.select_list_of_guards_for_additional_deployment_data_entry(text, str, date, value.Date, SystemConst._user_id); MessageBox.Show(dt.Rows.Count.ToString() + " Records Found"); if (dt.Rows.Count <= 0) { this.gdv_guards.DataSource = null; return; } this.gdv_guards.DataSource = dt; this.gdv_guards.Columns["auto_id"].Visible = false; this.gdv_guards.Columns["payment_month"].Visible = false; this.gdv_guards.Columns["branch"].ReadOnly = true; this.gdv_guards.Columns["guard_number"].ReadOnly = true; this.gdv_guards.Columns["days_worked"].ReadOnly = true; //this.gdv_guards.Columns["overtime"].ReadOnly = true; this.gdv_guards.Columns["days_absent"].ReadOnly = true; this.gdv_guards.Columns["full_name"].ReadOnly = true; this.gdv_guards.Columns["guard_number"].HeaderText = "Guard No."; this.gdv_guards.Columns["full_name"].HeaderText = "Name"; this.gdv_guards.Columns["branch"].HeaderText = "Branch"; this.gdv_guards.Columns["days_worked"].HeaderText = "Days"; this.gdv_guards.Columns["overtime"].HeaderText = "Ovt"; this.gdv_guards.Columns["days_absent"].HeaderText = "Absent"; this.gdv_guards.Columns["total_advance_in_month"].HeaderText = "Advance"; this.gdv_guards.Columns["total_arrears_in_month"].HeaderText = "Arrears"; this.gdv_guards.Columns["special_cash_additions"].HeaderText = "Special"; this.gdv_guards.Columns["residential_cost"].HeaderText = "Residential"; this.gdv_guards.Columns["uniform_costs"].HeaderText = "Uniform"; this.gdv_guards.Columns["local_service_tax_cost"].HeaderText = "LST"; this.gdv_guards.Columns["other_penalties_cost"].HeaderText = "Penalty"; this.gdv_guards.Columns["other_refunds"].HeaderText = "Refund"; this.gdv_guards.Columns["full_name"].Width = 250; this.gdv_guards.Columns["guard_number"].Width = 120; this.gdv_guards.Columns["residential_cost"].Width = 100; this.gdv_guards.RowsDefaultCellStyle.BackColor = Color.LightGray; this.gdv_guards.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; this.gdv_guards.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; this.gdv_guards.ColumnHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_guards.RowHeadersDefaultCellStyle.BackColor = Color.Black; this.gdv_guards.DefaultCellStyle.SelectionBackColor = Color.Cyan; this.gdv_guards.DefaultCellStyle.SelectionForeColor = Color.Black; this.gdv_guards.BorderStyle = BorderStyle.FixedSingle; foreach (DataGridViewColumn c in this.gdv_guards.Columns) { c.DefaultCellStyle.Font = new System.Drawing.Font("Arial", 11f, GraphicsUnit.Pixel); } this.gdv_guards.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue; this.gdv_guards.EnableHeadersVisualStyles = false; }
protected void Save_deployment_periods() { if (dt_start_date.Value.Date.Day != 1 && (dt_end_date.Value.Date.Day != 30 || dt_end_date.Value.Date.Day != 31)) { MessageBox.Show("Please select first and last days of the month only", "Deployment", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (lbl_guid.Text == "lbl_guid" && chk_active.Checked == true) { if (Guard_deployment.check_if_deployment_period_already_exists("check_if_deployment_period_already_exists", dt_start_date.Value.Date, dt_end_date.Value.Date) > 0) { MessageBox.Show("Deployment period already exists!!", "Deployment", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { DialogResult dialogResult = MessageBox.Show("This will save and set this deployment period as the active deployment,are you sure to proceed?", "Deployments", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { //call save function Guard_deployment.Save_new_deployment_period("save_new_deployment_period", dt_start_date.Value.Date, dt_end_date.Value.Date, chk_active.Checked == true ? true : false); return_deployment_periods(); Set_current_deployment_periods(); } else if (dialogResult == DialogResult.No) { //do nothing this.Visible = true; } } } else if (lbl_guid.Text == "lbl_guid" && chk_active.Checked == false) { if (Guard_deployment.check_if_deployment_period_already_exists("check_if_deployment_period_already_exists", dt_start_date.Value.Date, dt_end_date.Value.Date) > 0) { MessageBox.Show("Deployment period already exists!!", "Deployment", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { Guard_deployment.Save_new_deployment_period("save_new_deployment_period", dt_start_date.Value.Date, dt_end_date.Value.Date, chk_active.Checked == true ? true : false); return_deployment_periods(); } } else if (lbl_guid.Text != "lbl_guid" && chk_active.Checked == true) { DialogResult dialogResult = MessageBox.Show("Are you sure to set this as the current deployment period?", "Deployments", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { //call update function Guard_deployment.Set_active_deployment("set_active_deployment", Convert.ToInt32(lbl_guid.Text), chk_active.Checked == true ? true : false); return_deployment_periods(); Set_current_deployment_periods(); } else if (dialogResult == DialogResult.No) { //do nothing this.Visible = true; } } else if (lbl_guid.Text != "lbl_guid" && chk_active.Checked == false) { // MessageBox.Show("You cannot unset a deployment period before setting one,please set another deployment period and this will be unset automatically", "Deployments", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }