Ejemplo n.º 1
0
        public bool UpdateLeaveConfiguration(TBL_MP_HR_LeaveConfiguration model)
        {
            bool result = false;

            try
            {
                TBL_MP_HR_LeaveConfiguration dbModel = _dbContext.TBL_MP_HR_LeaveConfiguration.Where(x => x.PK_LeaveID == model.PK_LeaveID).FirstOrDefault();
                dbModel.FK_LeaveTypeID            = model.FK_LeaveTypeID;
                dbModel.MaxDaysAllow              = model.MaxDaysAllow;
                dbModel.CarryForwardLeave         = model.CarryForwardLeave;
                dbModel.CarryForwardLimitDays     = model.CarryForwardLimitDays;
                dbModel.ApplicableInProbation     = model.ApplicableInProbation;
                dbModel.LeaveEnchashable          = model.LeaveEnchashable;
                dbModel.EncashableSalaryHeadIDs   = model.EncashableSalaryHeadIDs;
                dbModel.EncashableSalaryHeadNames = model.EncashableSalaryHeadNames;
                dbModel.IsActive     = model.IsActive;
                dbModel.FK_FinYearID = model.FK_FinYearID;
                dbModel.FK_BranchID  = model.FK_BranchID;
                _dbContext.SaveChanges();
                result = true;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceLeaveConfiguration::UpdateLeaveConfiguration", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(result);
        }
Ejemplo n.º 2
0
 public void ScatterData()
 {
     try
     {
         TBL_MP_HR_LeaveConfiguration model = (new ServiceLeaveConfiguration()).GetLeaveInfoDbRecord(this.LeaveID);
         if (model != null)
         {
             txtLimitDays.Text                    = model.CarryForwardLimitDays.ToString();
             txtMaxDaysallow.Text                 = model.MaxDaysAllow.ToString();
             cboLeaveType.SelectedItem            = ((List <SelectListItem>)cboLeaveType.DataSource).Where(x => x.ID == model.FK_LeaveTypeID).FirstOrDefault();
             chkApplicableProbationPeriod.Checked = model.ApplicableInProbation;
             chkLeaveCarryForward.Checked         = model.CarryForwardLeave;
             chkLeaveEncashable.Checked           = model.LeaveEnchashable;
             chkIsActive.Checked                  = model.IsActive;
             this.SeledctedBranchID               = model.FK_BranchID;
             this.SeledctedYearID                 = model.FK_FinYearID;
             if (this.SeledctedBranchID != 0)
             {
                 cboBranch.SelectedItem = ((List <SelectListItem>)cboBranch.DataSource).Where(x => x.ID == this.SeledctedBranchID).FirstOrDefault();
             }
             if (this.SeledctedYearID != 0)
             {
                 cboYear.SelectedItem = ((List <SelectListItem>)cboYear.DataSource).Where(x => x.ID == this.SeledctedYearID).FirstOrDefault();
             }
             if (model.LeaveEnchashable)
             {
                 string[] IDs = model.EncashableSalaryHeadIDs.Split(',');
                 foreach (string headID in IDs)
                 {
                     foreach (DataGridViewRow mRow in gridAllounces.Rows)
                     {
                         if (mRow.Cells["ID"].Value.ToString().Trim() == headID.Trim())
                         {
                             mRow.Cells["IsActive"].Value = true;
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "frmAddEditLeaveConfiguration::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 3
0
        public TBL_MP_HR_LeaveConfiguration GetLeaveInfoDbRecord(int LeaveID)
        {
            TBL_MP_HR_LeaveConfiguration model = null;

            try
            {
                model = _dbContext.TBL_MP_HR_LeaveConfiguration.Where(x => x.PK_LeaveID == LeaveID).FirstOrDefault();
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceLeaveConfiguration::GetLeaveInfoDbRecord", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(model);
        }
Ejemplo n.º 4
0
        public int AddNewLeaveConfiguration(TBL_MP_HR_LeaveConfiguration model)
        {
            int newID = 0;

            try
            {
                _dbContext.TBL_MP_HR_LeaveConfiguration.Add(model);
                _dbContext.SaveChanges();
                newID = model.PK_LeaveID;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceLeaveConfiguration::AddNewLeaveConfiguration", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(newID);
        }
Ejemplo n.º 5
0
        public bool DeleteLeaveConfiguration(int ConfigID)
        {
            bool result = false;

            try
            {
                TBL_MP_HR_LeaveConfiguration model = _dbContext.TBL_MP_HR_LeaveConfiguration.Where(x => x.PK_LeaveID == ConfigID).FirstOrDefault();
                model.IsActive = false;
                _dbContext.SaveChanges();
                result = true;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceLeaveConfiguration::DeleteLeaveConfiguration", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(result);
        }
Ejemplo n.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            TBL_MP_HR_LeaveConfiguration model        = null;
            ServiceLeaveConfiguration    serviceLeave = new ServiceLeaveConfiguration();

            try
            {
                string strSalaryHeadIDs   = string.Empty;
                string strSalaryHeadNames = string.Empty;

                if (!this.ValidateChildren())
                {
                    return;
                }
                if (this.LeaveID == 0)
                {
                    model = new TBL_MP_HR_LeaveConfiguration();
                }
                else
                {
                    model = serviceLeave.GetLeaveInfoDbRecord(this.LeaveID);
                }

                #region GATHER DATA INTO MODEL FROM VIEW

                model.FK_LeaveTypeID        = ((SelectListItem)cboLeaveType.SelectedItem).ID;
                model.MaxDaysAllow          = decimal.Parse(txtMaxDaysallow.Text.Trim());
                model.CarryForwardLeave     = chkLeaveCarryForward.Checked;
                model.CarryForwardLimitDays = decimal.Parse(txtLimitDays.Text.Trim());
                model.ApplicableInProbation = chkApplicableProbationPeriod.Checked;
                model.LeaveEnchashable      = chkLeaveEncashable.Checked;
                model.IsActive     = chkIsActive.Checked;
                model.FK_BranchID  = ((SelectListItem)cboBranch.SelectedItem).ID;
                model.FK_FinYearID = ((SelectListItem)cboYear.SelectedItem).ID;

                #endregion
                #region PREPARE SALARY HEADS STRING
                if (chkLeaveEncashable.Checked)
                {
                    foreach (DataGridViewRow mRow in gridAllounces.Rows)
                    {
                        if ((bool)mRow.Cells["IsActive"].Value == true)
                        {
                            strSalaryHeadIDs   += mRow.Cells["ID"].Value.ToString() + ", ";
                            strSalaryHeadNames += mRow.Cells["Description"].Value.ToString() + ", ";
                        }
                    }
                }
                #endregion
                if (strSalaryHeadIDs.Trim() != string.Empty)
                {
                    model.EncashableSalaryHeadIDs = strSalaryHeadIDs.Trim().TrimEnd(',');
                }
                else
                {
                    model.EncashableSalaryHeadIDs = null;
                }
                if (strSalaryHeadNames.Trim() != string.Empty)
                {
                    model.EncashableSalaryHeadNames = strSalaryHeadNames.Trim().TrimEnd(',');
                }
                else
                {
                    model.EncashableSalaryHeadNames = null;
                }



                if (this.LeaveID == 0)
                {
                    this.LeaveID = serviceLeave.AddNewLeaveConfiguration(model);
                }
                else
                {
                    serviceLeave.UpdateLeaveConfiguration(model);
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmAddEditLeaveConfiguration::btnOk_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }