/// <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> /// 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); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdateHL_Click(object sender, DirectEventArgs e) { try { var salaryController = new SalaryDecisionController(); // upload file string path = string.Empty; if (cpfAttachHL.Visible && uploadAttachFileHL.HasFile) { path = UploadFile(uploadAttachFileHL, Constant.PathDecisionSalary); } var rs = JSON.Deserialize <List <SalaryDecisionModel> >(e.ExtraParams["json"]); foreach (var created in rs) { var hsl = new sal_SalaryDecision(); // decision information if (txtDecisionNumberHL.Visible) { hsl.DecisionNumber = txtDecisionNumberHL.Text.Trim(); } if (txtDecisionNameHL.Visible) { hsl.Name = txtDecisionNameHL.Text.Trim(); } if (DecisionDateHL.Visible && !DatetimeHelper.IsNull(DecisionDateHL.SelectedDate)) { hsl.DecisionDate = DecisionDateHL.SelectedDate; } if (EffectiveDateHL.Visible && !DatetimeHelper.IsNull(EffectiveDateHL.SelectedDate)) { hsl.EffectiveDate = EffectiveDateHL.SelectedDate; } if (txtDecisionMakerHL.Visible && !string.IsNullOrEmpty(txtDecisionMakerHL.Text)) { hsl.SignerName = txtDecisionMakerHL.Text; } var makerPosition = hdfIsMakerPositionHL.Text == @"0" ? cbxMakerPositionHL.Text : cbxMakerPositionHL.SelectedItem.Text; //hsl.SignerPosition = makerPosition; hsl.AttachFileName = path != "" ? path : hdfAttachFileHL.Text; hsl.Note = txtNoteHL.Text; // salary information hsl.RecordId = created.RecordId; hsl.QuantumId = created.QuantumId; //hsl.SalaryFactor = created.SalaryFactor; //hsl.SalaryBasic = created.SalaryBasic; //hsl.SalaryContract = created.SalaryContract; //hsl.SalaryInsurance = created.SalaryInsurance; //hsl.OutFrame = created.OutFrame; hsl.CreatedBy = CurrentUser.User.UserName; hsl.CreatedDate = DateTime.Now; SalaryDecisionController.Create(new SalaryDecisionModel(hsl)); } if (e.ExtraParams["close"] == "True") { wdCreateDecisionSalaryHL.Hide(); } gridDecisionSalaryEnterprise.Reload(); } catch (Exception ex) { Dialog.ShowError(ex.Message); } }
/// <summary> /// ############################################# /// Create salary decision for employee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, DirectEventArgs e) { try { var hsl = new sal_SalaryDecision(); // upload file var path = string.Empty; if (uploadAttachFile.HasFile) { path = UploadFile(uploadAttachFile, Constant.PathDecisionSalary); } // decide information if (!string.IsNullOrEmpty(hdfChooseEmployee.Text)) { hsl.RecordId = Convert.ToInt32(hdfChooseEmployee.Text); } if (txtDecisionNumberNew.Visible) { hsl.DecisionNumber = txtDecisionNumberNew.Text; } if (!DatetimeHelper.IsNull(DecisionDateNew.SelectedDate)) { hsl.DecisionDate = DecisionDateNew.SelectedDate; } if (txtDecisionNameNew.Visible) { hsl.Name = txtDecisionNameNew.Text; } if (!DatetimeHelper.IsNull(EffectiveDateNew.SelectedDate)) { hsl.EffectiveDate = EffectiveDateNew.SelectedDate; } if (txtDecisionMakerNew.Visible) { hsl.SignerName = txtDecisionMakerNew.Text; } var makerPosition = hdfIsMakerPosition.Text == @"0" ? cbxMakerPosition.Text : cbxMakerPosition.SelectedItem.Text; //hsl.SignerPosition = makerPosition; if (cbxContractTypeNew.SelectedItem.Value != null) { hsl.ContractId = Convert.ToInt32(hdfContractTypeNew.Text); } // attach file hsl.AttachFileName = path != "" ? path : hdfAttachFile.Text; if (txtNoteNew.Visible) { hsl.Note = txtNoteNew.Text; } // salary information //if (!string.IsNullOrEmpty(txtSalaryBasicNew.Text)) // hsl.SalaryBasic = double.Parse(txtSalaryBasicNew.Text); //if (!string.IsNullOrEmpty(txtSalaryContractNew.Text)) // hsl.SalaryContract = double.Parse(txtSalaryContractNew.Text); //if (!string.IsNullOrEmpty(txtSalaryGrossNew.Text)) // hsl.SalaryGross = double.Parse(txtSalaryGrossNew.Text); //if (!string.IsNullOrEmpty(txtSalaryNetNew.Text)) // hsl.SalaryNet = double.Parse(txtSalaryNetNew.Text); //if (!string.IsNullOrEmpty(txtPercentageSalaryNew.Text)) // hsl.PercentageSalary = double.Parse(txtPercentageSalaryNew.Text); //if (!string.IsNullOrEmpty(txtSalaryInsuranceNew.Text)) // hsl.SalaryInsurance = double.Parse(txtSalaryInsuranceNew.Text); //if (!string.IsNullOrEmpty(txtSalaryFactorNew.Text)) // hsl.SalaryFactor = double.Parse(txtSalaryFactorNew.Text); hsl.CreatedBy = CurrentUser.User.UserName; hsl.CreatedDate = DateTime.Now; if (e.ExtraParams["Command"] == "Edit") { hsl.Id = int.Parse("0" + hdfRecordId.Text); SalaryDecisionController.Update(new SalaryDecisionModel(hsl)); wdCreateDecisionSalary.Hide(); } else { // add salary decision SalaryDecisionController.Create(new SalaryDecisionModel(hsl)); if (e.ExtraParams["Close"] == "True") { wdCreateDecisionSalary.Hide(); } } gridDecisionSalaryEnterprise.Reload(); } catch (Exception ex) { X.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra khi lưu quyết định lương: " + ex.Message).Show(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCapNhatHL_Click(object sender, DirectEventArgs e) { try { var salaryController = new SalaryDecisionController(); var errorStr = string.Empty; // upload file var path = string.Empty; if (cpfAttachHL.Visible && fufTepTinDinhKemHL.HasFile) { path = UploadFile(fufTepTinDinhKemHL, Constant.PathDecisionSalary); } var rs = JSON.Deserialize <List <SalaryDecisionModel> >(e.ExtraParams["json"]); foreach (var created in rs) { var hsl = new sal_SalaryDecision(); // decision information if (txtSoQDHL.Visible) { hsl.DecisionNumber = txtSoQDHL.Text.Trim(); } if (txtTenQDHL.Visible) { hsl.Name = txtTenQDHL.Text.Trim(); } if (dfNgayQDHL.Visible && !DatetimeHelper.IsNull(dfNgayQDHL.SelectedDate)) { hsl.DecisionDate = dfNgayQDHL.SelectedDate; } if (dfNgayHieuLucHL.Visible && !DatetimeHelper.IsNull(dfNgayHieuLucHL.SelectedDate)) { hsl.EffectiveDate = dfNgayHieuLucHL.SelectedDate; } if (txtNguoiQDHL.Visible && !string.IsNullOrEmpty(txtNguoiQDHL.Text)) { hsl.SignerName = txtNguoiQDHL.Text; } var makerPosition = hdfIsMakerPositionHL.Text == @"0" ? cbxMakerPositionHL.Text : cbxMakerPositionHL.SelectedItem.Text; //hsl.SignerPosition = makerPosition; hsl.AttachFileName = path != "" ? path : hdfTepTinDinhKemHL.Text; hsl.Note = txtGhiChuHL.Text; // salary information hsl.RecordId = created.RecordId; hsl.QuantumId = created.QuantumId; //hsl.SalaryFactor = created.SalaryFactor; //hsl.SalaryBasic = created.SalaryBasic; //hsl.SalaryInsurance = created.SalaryInsurance; //hsl.OutFrame = created.OutFrame; hsl.CreatedBy = CurrentUser.User.UserName; hsl.CreatedDate = DateTime.Now; SalaryDecisionController.Create(new SalaryDecisionModel(hsl)); } if (e.ExtraParams["close"] == "True") { wdTaoQuyetDinhLuongHangLoat.Hide(); } else { RM.RegisterClientScriptBlock("resetform", "ResetWdTaoQuyetDinhLuongHangLoat(); Ext.net.DirectMethods.GenerateSoQDHL();"); } GridPanel1.Reload(); RM.RegisterClientScriptBlock("rlst", "Store1.reload();"); } catch (Exception ex) { Dialog.ShowError(ex.Message); } }
/// <summary> /// ############################################# /// Create salary decision for employee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCapNhat_Click(object sender, DirectEventArgs e) { try { var hsl = new sal_SalaryDecision(); // upload file var path = string.Empty; if (fufTepTinDinhKem.HasFile) { path = UploadFile(fufTepTinDinhKem, Constant.PathDecisionSalary); } // decide information if (!string.IsNullOrEmpty(hdfChonCanBo.Text)) { hsl.RecordId = Convert.ToInt32(hdfChonCanBo.Text); } if (txtSoQDMoi.Visible) { hsl.DecisionNumber = txtSoQDMoi.Text; } if (!DatetimeHelper.IsNull(dfNgayQDMoi.SelectedDate)) { hsl.DecisionDate = dfNgayQDMoi.SelectedDate; } if (txtTenQDMoi.Visible) { hsl.Name = txtTenQDMoi.Text; } if (!DatetimeHelper.IsNull(dfNgayHieuLucMoi.SelectedDate)) { hsl.EffectiveDate = dfNgayHieuLucMoi.SelectedDate; } if (txtNguoiQD.Visible) { hsl.SignerName = txtNguoiQD.Text; } var makerPosition = hdfIsMakerPosition.Text == @"0" ? cbxMakerPosition.Text : cbxMakerPosition.SelectedItem.Text; //hsl.SignerPosition = makerPosition; if (cbHopDongLoaiHopDongMoi.SelectedItem.Value != null) { hsl.ContractId = Convert.ToInt32(hdfLoaiHopDong.Text); } // attach file hsl.AttachFileName = path != "" ? path : hdfTepTinDinhKem.Text; if (txtGhiChuMoi.Visible) { hsl.Note = txtGhiChuMoi.Text; } // salary information //if(cbx_ngachMoi.Visible) // hsl.QuantumId = Convert.ToInt32(hdfQuantumId.Text); // hsl.SalaryFactor = double.Parse(txtHeSoLuongMoi.Text.Replace('.', ',')); //if(txtMucLuongMoi.Visible && !string.IsNullOrEmpty(txtMucLuongMoi.Text)) // hsl.SalaryBasic = double.Parse(txtMucLuongMoi.Text.Replace('.', ',')); //if(txtLuongDongBHMoi.Visible && !string.IsNullOrEmpty(txtLuongDongBHMoi.Text)) // hsl.SalaryInsurance = double.Parse(txtLuongDongBHMoi.Text.Replace('.', ',')); //if(txtBacLuongNBMoi.Visible) // hsl.SalaryGradeLift = txtBacLuongNBMoi.Text; //if(dfNgayHLNBMoi.Visible && !util.IsDateNull(dfNgayHLNBMoi.SelectedDate)) // hsl.SalaryGradeDate = dfNgayHLNBMoi.SelectedDate; //if(txtVuotKhungMoi.Visible && !string.IsNullOrEmpty(txtVuotKhungMoi.Text)) // hsl.OutFrame = double.Parse("0" + txtVuotKhungMoi.Text); //if(txtThamnien.Visible && !string.IsNullOrEmpty(txtThamnien.Text)) // hsl.Seniority = double.Parse("0" + txtThamnien.Text); //if(chkNangNgach.Checked == true) // hsl.IsLiftQuantum = true; hsl.CreatedBy = CurrentUser.User.UserName; hsl.CreatedDate = DateTime.Now; if (e.ExtraParams["Command"] == "Edit") { hsl.Id = int.Parse("0" + hdfRecordId.Text); SalaryDecisionController.Update(new SalaryDecisionModel(hsl)); wdTaoQuyetDinhLuong.Hide(); } else { // add salary decision SalaryDecisionController.Create(new SalaryDecisionModel(hsl)); if (e.ExtraParams["Close"] == "True") { wdTaoQuyetDinhLuong.Hide(); } else { RM.RegisterClientScriptBlock("resetform1", "ResetWdTaoQuyetDinhLuong(); Ext.net.DirectMethods.GenerateSoQD();"); } } RM.RegisterClientScriptBlock("rlgr", "Store1.reload();"); } catch (Exception ex) { X.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra khi lưu quyết định lương: " + ex.Message).Show(); } }