Exemplo n.º 1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (IsCorrectData())
     {
         using (LeaveApplication leave = new LeaveApplication())
         {
             leave.LeaveCode = txtLeaveCode.Text;
             leave.Fill();
             leave.Reason       = txtReason.Text;
             leave.ApproverDate = clsDateTime.CombineDateTime(dtpApproverDate.Value, dtpApproverTime.Value);
             leave.Status       = cmbStatus.SelectedValue.ToString();
             leave.UpdateAdmin();
             if (cmbStatus.SelectedValue.ToString() == "A" && _strStatus != "A" && LeaveApplicationTypes.IsHasBalance(_strLeaveTypeCode))
             {
                 LeaveApplicationBalance.DeductLeaveBalance(clsValidator.CheckFloat(txtUnits.Text), _strUsername, _strLeaveTypeCode);
             }
             else if (cmbStatus.SelectedValue.ToString() != "A" && _strStatus == "A" && LeaveApplicationTypes.IsHasBalance(_strLeaveTypeCode))
             {
                 LeaveApplicationBalance.AddLeaveBalance(clsValidator.CheckFloat(txtUnits.Text), _strUsername, _strLeaveTypeCode);
             }
         }
         _frmLeaveList.BindLeaveList();
         this.Close();
     }
 }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsCorrectData())
            {
                DateTime dteDateStart = clsDateTime.CombineDateTime(dtpDateStart.Value, cmbTimeFrom.Text);
                DateTime dteDateEnd   = clsDateTime.CombineDateTime(dtpDateEnd.Value, cmbTimeTo.Text);
                if (!LeaveApplication.HasExistingApplication(cmbRequestor.SelectedValue.ToString(), dteDateStart, dteDateEnd))
                {
                    LeaveApplication leave = new LeaveApplication();
                    leave.LeaveCode       = txtLeaveCode.Text;
                    leave.LeaveType       = cmbLeaveType.SelectedValue.ToString();
                    leave.Requestor       = cmbRequestor.SelectedValue.ToString();
                    leave.DateFile        = DateTime.Now;
                    leave.DateStart       = dteDateStart;
                    leave.DateEnd         = dteDateEnd;
                    leave.Units           = clsValidator.CheckFloat(txtUnits.Text);
                    leave.Reason          = txtReason.Text;
                    leave.Approver        = cmbApprover.SelectedValue.ToString();
                    leave.ApproverDate    = clsDateTime.CombineDateTime(dtpDateEnd.Value, dtpApproverTime.Value);
                    leave.ApproverRemarks = txtARemarks.Text;
                    leave.Status          = cmbStatus.SelectedValue.ToString();
                    leave.InsertAdmin();
                    MessageBox.Show("save");

                    if (cmbStatus.SelectedValue.ToString() == "A" && LeaveApplicationTypes.IsHasBalance(cmbLeaveType.SelectedValue.ToString()))
                    {
                        LeaveApplicationBalance.DeductLeaveBalance(clsValidator.CheckFloat(txtUnits.Text), cmbRequestor.SelectedValue.ToString(), cmbLeaveType.SelectedValue.ToString());
                    }

                    _frmLeaveList.BindLeaveList();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("There is already an existing leave application on specified dates.", clsMessageBox.MessageBoxText, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }