/// <summary> /// Delete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Delete(object sender, DirectEventArgs e) { try { if (!string.IsNullOrEmpty(hdfId.Text)) { var decision = DecisionController.GetById(Convert.ToInt32(hdfId.Text)); if (decision != null) { //delete decrease insurance var insurance = FluctuationInsuranceController.GetByRecordId(decision.RecordId, decision.DecisionDate.Month, decision.DecisionDate.Year); if (insurance != null) { FluctuationInsuranceController.Delete(insurance.Id); } } //delete DecisionController.Delete(Convert.ToInt32(hdfId.Text)); } // reload data gpDecision.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> /// /// </summary> /// <param name="id"></param> private void InitFormUpdate(int id) { // get current decision var model = SalaryDecisionController.GetById(id); if (model != null) { // get previous decision var previousDecision = SalaryDecisionController.GetPrevious(model.RecordId); // bind previous data if (previousDecision != null) { txtCurrName.Text = previousDecision.Name; txtCurrDecisionNumber.Text = previousDecision.DecisionNumber; txtCurrDecisionDate.Text = previousDecision.DecisionDate.ToString("dd/MM/yyyy"); txtCurrSignerName.Text = previousDecision.SignerName; txtCurrSignerPosition.Text = previousDecision.SignerPosition; txtCurrContractTypeName.Text = previousDecision.ContractTypeName; txtCurrBasicSalary.Text = previousDecision.BasicSalary.ToString("#,###"); txtCurrFactor.Text = previousDecision.Factor.ToString("#,##0.00"); txtCurrGrossSalary.Text = previousDecision.GrossSalary.ToString("#,###"); txtCurrNetSalary.Text = previousDecision.NetSalary.ToString("#,###"); txtCurrContractSalary.Text = previousDecision.ContractSalary.ToString("#,###"); txtCurrInsuranceSalary.Text = previousDecision.InsuranceSalary.ToString("#,###"); txtCurrPercentageLeader.Text = previousDecision.PercentageLeader.ToString("0.00 %"); } // bind current salary decision cboEmployee.Text = model.EmployeeName; hdfEmployee.Text = model.RecordId.ToString(); txtName.Text = model.Name; txtDepartmentName.Text = model.DepartmentName; txtPositionName.Text = model.PositionName; txtJobTitleName.Text = model.JobTitleName; cboContractType.Text = model.ContractTypeName; txtDecisionNumber.Text = model.DecisionNumber; dfDecisionDate.SelectedDate = model.DecisionDate; dfEffectiveDate.SelectedDate = model.EditedDate; txtSignerName.Text = model.SignerName; hdfPosition.Text = model.SignerPositionId.ToString(); cboPosition.Text = model.SignerPosition; txtNote.Text = model.Note; txtBasicSalary.Text = model.BasicSalary.ToString("#,###"); txtFactor.Text = model.Factor.ToString("#,##0.00"); txtGrossSalary.Text = model.GrossSalary.ToString("#,###"); txtNetSalary.Text = model.NetSalary.ToString("#,###"); txtContractSalary.Text = model.ContractSalary.ToString("#,###"); txtInsuranceSalary.Text = model.InsuranceSalary.ToString("#,###"); txtPercentageSalary.Text = model.PercentageSalary.ToString("0.00"); txtPercentageLeader.Text = model.PercentageLeader.ToString("0.00"); txtPercentageOverGrade.Text = model.PercentageOverGrade.ToString("0.00"); // get file upload if (cfAttachFile.Visible) { hdfAttachFile.Text = model.AttachFileName; if (!string.IsNullOrEmpty(model.AttachFileName)) { hdfAttachFile.Text = model.AttachFileName; fufAttachFile.Text = GetFileName(model.AttachFileName); } } //insurance var insurance = FluctuationInsuranceController.GetByRecordId(model.RecordId, model.EffectiveDate.Month, model.EffectiveDate.Year); if (insurance != null) { hdfReason.Text = insurance.ReasonId.ToString(); cboReason.Text = insurance.ReasonName; hdfInsuranceType.Text = ((int)insurance.Type).ToString(); if (insurance.Type != 0) { cboInsuranceType.Text = insurance.TypeName; } if (!string.IsNullOrEmpty(hdfInsuranceType.Text)) { cboReason.Show(); } } else { //reset insurance ResetInsurance(); } } }