/// <summary> /// Lưu phụ cấp /// </summary> /// <param name="model"></param> private void ProcessAllowance(SalaryDecisionModel model) { // check edit data if (string.IsNullOrEmpty(hdfEditData.Text)) { return; } // get list data var allowances = JSON.Deserialize <List <SalaryAllowanceModel> >(hdfEditData.Text); // group latest salary allowance by code allowances = allowances.GroupBy(r => r.AllowanceCode) .Select(g => g.OrderByDescending(c => c.CreatedDate).FirstOrDefault()).ToList(); // create and update foreach (var allowance in allowances) { if (allowance.Id == 0) { allowance.SalaryDecisionId = model.Id; SalaryAllowanceController.Create(allowance); } else { SalaryAllowanceController.Update(allowance); } } }
/// <summary> /// /// </summary> /// <param name="model"></param> private void EditDataMany(SalaryDecisionModel model) { var util = new ConvertUtils(); if (!string.IsNullOrEmpty(hdfPositionMany.Text)) { model.SignerPositionId = Convert.ToInt32(hdfPositionMany.Text); } model.Name = txtNameMany.Text; model.DecisionNumber = txtDecisionNumberMany.Text; if (!util.IsDateNull(dfDecisionDateMany.SelectedDate)) { model.DecisionDate = dfDecisionDateMany.SelectedDate; } if (!util.IsDateNull(dfEffectiveDateMany.SelectedDate)) { model.EffectiveDate = dfEffectiveDateMany.SelectedDate; } model.SignerName = txtSignerNameMany.Text; model.Note = txtNoteMany.Text; if (!string.IsNullOrEmpty(txtGrossSalaryMany.Text)) { model.GrossSalary = Convert.ToDecimal(txtGrossSalaryMany.Text); } if (!string.IsNullOrEmpty(txtContractSalaryMany.Text)) { model.ContractSalary = Convert.ToDecimal(txtContractSalaryMany.Text); } if (!string.IsNullOrEmpty(txtPercentageSalaryMany.Text)) { model.PercentageSalary = Convert.ToDecimal(txtPercentageSalaryMany.Text); } if (!string.IsNullOrEmpty(txtFactorMany.Text)) { model.Factor = Convert.ToDecimal(txtFactorMany.Text); } if (!string.IsNullOrEmpty(txtNetSalaryMany.Text)) { model.NetSalary = Convert.ToDecimal(txtNetSalaryMany.Text); } if (!string.IsNullOrEmpty(txtInsuranceSalaryMany.Text)) { model.InsuranceSalary = Convert.ToDecimal(txtInsuranceSalaryMany.Text); } if (!string.IsNullOrEmpty(txtPercentageLeaderMany.Text)) { model.PercentageLeader = Convert.ToDecimal(txtPercentageLeaderMany.Text); } // upload file var path = string.Empty; if (fufAttachFileMany.HasFile) { path = UploadFile(fufAttachFileMany, Constant.PathDecisionSalary); } model.AttachFileName = path != "" ? path : hdfAttachFileMany.Text; }
/// <summary> /// /// </summary> /// <param name="model"></param> private void EditDataMany(SalaryDecisionModel model) { var util = new ConvertUtils(); if (!string.IsNullOrEmpty(hdfPositionMany.Text)) { model.SignerPositionId = Convert.ToInt32(hdfPositionMany.Text); } model.Name = txtNameMany.Text; model.DecisionNumber = txtDecisionNumberMany.Text; if (!util.IsDateNull(dfDecisionDateMany.SelectedDate)) { model.DecisionDate = dfDecisionDateMany.SelectedDate; } if (!util.IsDateNull(dfEffectiveDateMany.SelectedDate)) { model.EffectiveDate = dfEffectiveDateMany.SelectedDate; } model.SignerName = txtSignerNameMany.Text; model.Note = txtNoteMany.Text; if (!string.IsNullOrEmpty(hdfQuantumIdMany.Text)) { model.QuantumId = Convert.ToInt32(hdfQuantumIdMany.Text); var quantum = CatalogQuantumController.GetById(Convert.ToInt32(hdfQuantumIdMany.Text)); if (quantum != null) { model.GroupQuantumId = quantum.GroupQuantumId; } } if (!string.IsNullOrEmpty(hdfSalaryGradeMany.Text)) { model.Grade = Convert.ToInt32(hdfSalaryGradeMany.Text); } if (!string.IsNullOrEmpty(txtPercentageSalaryMany.Text)) { model.PercentageSalary = Convert.ToDecimal(txtPercentageSalaryMany.Text); } if (!string.IsNullOrEmpty(txtFactorMany.Text)) { model.Factor = Convert.ToDecimal(txtFactorMany.Text); } if (!string.IsNullOrEmpty(txtPercentageLeaderMany.Text)) { model.PercentageLeader = Convert.ToDecimal(txtPercentageLeaderMany.Text); } // upload file var path = string.Empty; if (fufAttachFileMany.HasFile) { path = UploadFile(fufAttachFileMany, Constant.PathDecisionSalary); } model.AttachFileName = path != "" ? path : hdfAttachFileMany.Text; }
/// <summary> /// Insert or Update decision one employee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertOrUpdate(object sender, DirectEventArgs e) { try { // init model var model = new SalaryDecisionModel() { EditedBy = CurrentUser.User.UserName }; // check id if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0) { var result = SalaryDecisionController.GetById(Convert.ToInt32(hdfId.Text));; if (result != null) { model = result; } } // set new props for model model.Status = !string.IsNullOrEmpty(hdfStatus.Text) ? (SalaryDecisionStatus)Convert.ToInt32(hdfStatus.Text) : SalaryDecisionStatus.Approved; //edit data EditData(model); // check model id if (model.Id > 0) { // update SalaryDecisionController.Update(model); } else { // set created user model.CreatedBy = CurrentUser.User.UserName; // insert SalaryDecisionController.Create(model); } // hide window wdSetting.Hide(); //reset form ResetForm(); // reload data gpSalaryDecision.Reload(); } catch (Exception exception) { Dialog.ShowError(exception); } }
/// <summary> /// /// </summary> /// <param name="model"></param> private void ProcessInsurance(SalaryDecisionModel model) { var insuranceModel = new FluctuationInsuranceModel() { RecordId = model.RecordId, ReasonId = !string.IsNullOrEmpty(hdfReason.Text) ? Convert.ToInt32(hdfReason.Text) : 0, EffectiveDate = model.EffectiveDate, CreatedBy = CurrentUser.User.UserName, CreatedDate = DateTime.Now, EditedBy = "", EditedDate = DateTime.Now }; if (!string.IsNullOrEmpty(hdfInsuranceType.Text)) { insuranceModel.Type = (InsuranceType)Enum.Parse(typeof(InsuranceType), hdfInsuranceType.Text); } //check exist insurance var checkModel = FluctuationInsuranceController.GetByRecordId(model.RecordId, insuranceModel.EffectiveDate.Month, insuranceModel.EffectiveDate.Year); if (checkModel != null) { //update insuranceModel.Id = checkModel.Id; insuranceModel.EditedBy = CurrentUser.User.UserName; insuranceModel.EditedDate = DateTime.Now; //update FluctuationInsuranceController.Update(insuranceModel); } else { //create FluctuationInsuranceController.Create(insuranceModel); } }
/// <summary> /// Insert or Update decision many employee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertMany(object sender, DirectEventArgs e) { try { foreach (var employee in chkEmployeeRowSelection.SelectedRows) { // init model var model = new SalaryDecisionModel { RecordId = Convert.ToInt32(employee.RecordID), CreatedBy = CurrentUser.User.UserName, EditedBy = CurrentUser.User.UserName, Status = !string.IsNullOrEmpty(hdfStatus.Text) ? (SalaryDecisionStatus)Convert.ToInt32(hdfStatus.Text) : SalaryDecisionStatus.Approved }; //edit data EditDataMany(model); // insert SalaryDecisionController.Create(model); } // hide window wdSettingMany.Hide(); //reset form ResetForm(); // reload data gpSalaryDecision.Reload(); } catch (Exception exception) { Dialog.ShowError(exception); } }