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 btnExcludeAll_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem itm in lvIncluded.Items)
            {
                bool   blnCancelLeave   = false;
                bool   blnHasBalance    = false;
                string strLeaveTypeCode = "";
                string strUsername      = itm.Tag.ToString();
                string strLeaveCode     = CDL.GetLeaveCode(strUsername, _strCDLCode);

                using (LeaveApplication leave = new LeaveApplication())
                {
                    leave.LeaveCode = strLeaveCode;
                    leave.Fill();
                    strLeaveTypeCode = leave.LeaveType;
                    leave.Status     = "C";
                    blnCancelLeave   = leave.UpdateAdmin() > 0;
                }
                blnHasBalance = LeaveApplicationTypes.IsHasBalance(strLeaveTypeCode);

                if (blnHasBalance && blnCancelLeave)
                {
                    LeaveApplicationBalance.AddLeaveBalance(1, strUsername, strLeaveTypeCode);
                }

                if (blnCancelLeave)
                {
                    CDL.RemoveMember(_strCDLCode, strUsername);
                }
            }
            this.BindList();
        }