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(); }
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(); } }