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);
         }
     }
 }
 protected void Save_deployment_periods()
 {
     if (this.dt_start_date.Value.Date.Day != 1 && (this.dt_end_date.Value.Date.Day != 30 || this.dt_end_date.Value.Date.Day != 31))
     {
         MessageBox.Show("Please select first and last days of the month only", "Deployment", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return;
     }
     if (!(this.lbl_guid.Text == "lbl_guid") || !this.chk_active.Checked)
     {
         if (this.lbl_guid.Text == "lbl_guid" && !this.chk_active.Checked)
         {
             if (Guard_deployment.check_if_deployment_period_already_exists("check_if_deployment_period_already_exists", this.dt_start_date.Value.Date, this.dt_end_date.Value.Date) > 0)
             {
                 MessageBox.Show("Deployment period already exists!!", "Deployment", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
             Guard_deployment.Save_new_deployment_period("save_new_deployment_period", this.dt_start_date.Value.Date, this.dt_end_date.Value.Date, (this.chk_active.Checked ? true : false));
             this.return_deployment_periods();
             return;
         }
         if (this.lbl_guid.Text != "lbl_guid" && this.chk_active.Checked)
         {
             System.Windows.Forms.DialogResult dialogResult = MessageBox.Show("Are you sure to set this as the current deployment period?", "Deployments", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
             if (dialogResult == System.Windows.Forms.DialogResult.Yes)
             {
                 Guard_deployment.Set_active_deployment("set_active_deployment", Convert.ToInt32(this.lbl_guid.Text), (this.chk_active.Checked ? true : false));
                 this.return_deployment_periods();
                 this.Set_current_deployment_periods();
                 return;
             }
             if (dialogResult == System.Windows.Forms.DialogResult.No)
             {
                 base.Visible = true;
                 return;
             }
         }
         else if (this.lbl_guid.Text != "lbl_guid")
         {
             bool @checked = this.chk_active.Checked;
         }
     }
     else
     {
         if (Guard_deployment.check_if_deployment_period_already_exists("check_if_deployment_period_already_exists", this.dt_start_date.Value.Date, this.dt_end_date.Value.Date) > 0)
         {
             MessageBox.Show("Deployment period already exists!!", "Deployment", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return;
         }
         System.Windows.Forms.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.Exclamation);
         if (dialogResult == System.Windows.Forms.DialogResult.Yes)
         {
             Guard_deployment.Save_new_deployment_period("save_new_deployment_period", this.dt_start_date.Value.Date, this.dt_end_date.Value.Date, (this.chk_active.Checked ? true : false));
             this.return_deployment_periods();
             this.Set_current_deployment_periods();
             return;
         }
         if (dialogResult == System.Windows.Forms.DialogResult.No)
         {
             base.Visible = true;
             return;
         }
     }
 }