/// <summary> /// Delete catalog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Delete(object sender, DirectEventArgs e) { try { // init id var param = e.ExtraParams["Id"]; // parse id if (!int.TryParse(param, out var id) || id <= 0) { // parse error, show error Dialog.ShowError("Có lỗi xảy ra trong quá trình xử lý"); return; } // delete CatalogController.Delete(hdfObjName.Text, id); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục {0}".FormatWith(hdfObjName.Text), SystemAction.Delete, "Xóa danh mục {0}".FormatWith(id))); // reload data gpCatalog.Reload(); } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục {0} - Delete".FormatWith(hdfObjName.Text), ex)); } }
/// <summary> /// Delete catalog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Delete(object sender, DirectEventArgs e) { try { // init id var param = e.ExtraParams["Id"]; // parse id if (!int.TryParse(param, out var id) || id <= 0) { // parse error, show error Dialog.ShowError("Có lỗi xảy ra trong quá trình xử lý"); return; } // delete CatalogBasicSalaryController.Delete(id); // reload data gpCatalog.Reload(); } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục lương cơ bản - Delete", ex)); } }
/// <summary> /// Init setting window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InitWindow(object sender, DirectEventArgs e) { try { // init id var param = e.ExtraParams["Id"]; // parse id if (int.TryParse(param, out var id)) { // init window props if (id > 0) { // edit wdSetting.Title = @"Sửa"; wdSetting.Icon = Icon.Pencil; } else { // insert wdSetting.Title = @"Thêm mới"; wdSetting.Icon = Icon.Add; } // init id hdfId.Text = id.ToString(); // init object var model = new CatalogQuantumModel(); // check id if (id > 0) { var result = CatalogQuantumController.GetById(id); if (result != null) { model = result; } } // set catalog props txtName.Text = model.Name; txtDescription.Text = model.Description; hdfGroupQuantum.Text = model.GroupQuantumId.ToString(); cboGroupQuantum.Text = model.GroupQuantumName; txtOrder.Text = model.Order.ToString(); hdfStatus.Text = ((int)model.Status).ToString(); cboStatus.Text = model.Status.Description(); // show window wdSetting.Show(); } } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục ngạch - InitWindow", ex)); } }
/// <summary> /// Logout /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Logout(object sender, DirectEventArgs e) { // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Default", SystemAction.Logout, SystemLogType.UserAction, "Đăng xuất")); // logout Session.Abandon(); // redirect to login page Response.Redirect(Resource.Get("LoginUrl"), true); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void cboEmployee_Selected(object sender, DirectEventArgs e) { try { if (!string.IsNullOrEmpty(cboEmployee.SelectedItem.Value)) { var record = RecordController.GetById(Convert.ToInt32(cboEmployee.SelectedItem.Value)); if (record != null) { // bind record data txtDepartmentName.Text = record.DepartmentName; txtPositionName.Text = record.PositionName; txtJobTitleName.Text = record.JobTitleName; // get current salary decision var salaryDecsion = SalaryDecisionController.GetCurrent(record.Id); if (salaryDecsion != null) { // bind current salary decision txtCurrName.Text = salaryDecsion.Name; txtCurrDecisionNumber.Text = salaryDecsion.DecisionNumber; txtCurrDecisionDate.Text = salaryDecsion.DecisionDate.ToString("dd/MM/yyyy"); txtCurrSignerName.Text = salaryDecsion.SignerName; txtCurrSignerPosition.Text = salaryDecsion.SignerPosition; txtCurrContractTypeName.Text = salaryDecsion.ContractTypeName; txtCurrBasicSalary.Text = salaryDecsion.BasicSalary.ToString("#,###"); txtCurrFactor.Text = salaryDecsion.Factor.ToString("#,###.00"); txtCurrGrossSalary.Text = salaryDecsion.GrossSalary.ToString("#,###"); txtCurrNetSalary.Text = salaryDecsion.NetSalary.ToString("#,###"); txtCurrContractSalary.Text = salaryDecsion.ContractSalary.ToString("#,###"); txtCurrInsuranceSalary.Text = salaryDecsion.InsuranceSalary.ToString("#,###"); txtCurrPercentageLeader.Text = salaryDecsion.PercentageLeader.ToString("0.00 %"); // bind new salary decision txtBasicSalary.Text = salaryDecsion.BasicSalary.ToString("#,###"); txtPercentageLeader.Text = salaryDecsion.PercentageLeader.ToString("0.00"); txtPercentageOverGrade.Text = salaryDecsion.PercentageOverGrade.ToString("0.00"); } } } } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Diễn biến lương - cboEmployee_Selected", ex)); } }
public void ProcessLogin() { try { // init return message var message = string.Empty; // init user model var userModel = new UserModel { // authenticate User = UserServices.Authenticate(txtUserName.Text.Trim(), txtPassword.Text, ref message) }; // check user login if (userModel.User == null) { // login fail Dialog.ShowError("Login Fail", message); return; } // check departments if (userModel.Departments.Count > 0) { // log action SystemLogController.Create(new SystemLogModel(userModel.User.UserName, "Default", SystemAction.Login, SystemLogType.UserAction, "Đăng nhập")); // set current user Session["CurrentUser"] = userModel; // redirect home page Response.Redirect("~/Default.aspx"); } else { // alert error message Dialog.ShowError("No Department", "Người dùng chưa được cấp quyền với bất kỳ đơn vị nào."); // redirect login page Response.Redirect(Resource.Get("LoginUrl")); } } catch (Exception ex) { Dialog.ShowError(ex); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDownloadAttachFile_ClickMany(object sender, DirectEventArgs e) { try { DownloadAttachFile("sal_SalaryDecision", hdfAttachFileMany); } catch (Exception ex) { // show dialog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Diễn biến lương - btnDownloadAttachFile_Click", ex)); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDeleteAttachFile_ClickMany(object sender, DirectEventArgs e) { try { if (!string.IsNullOrEmpty(hdfId.Text)) { DeleteAttachFile("sal_SalaryDecision", int.Parse("0" + hdfId.Text), hdfAttachFileMany); hdfAttachFile.Text = ""; } } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Diễn biến lương - btnDeleteAttachFile_Click", ex)); } }
/// <summary> /// Update password /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void UpdatePassword(object sender, DirectEventArgs e) { // init return mesage var message = string.Empty; // update password if (UserServices.ChangePassword(CurrentUser.User.UserName, txtOldPassword.Text, txtNewPassword.Text, ref message) != null) { // update success Dialog.ShowNotification(message); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Default", SystemAction.Other, SystemLogType.UserAction, "Đổi mật khẩu")); } else { // show error Dialog.ShowError(message); } // hide window wdChangePassword.Hide(); }
/// <summary> /// Init setting window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InitWindow(object sender, DirectEventArgs e) { try { // init id var param = e.ExtraParams["Id"]; // parse id if (int.TryParse(param, out var id)) { // init window props if (id > 0) { // edit wdSetting.Title = @"Sửa"; wdSetting.Icon = Icon.Pencil; } else { // insert wdSetting.Title = @"Thêm mới"; wdSetting.Icon = Icon.Add; } // init id hdfId.Text = id.ToString(); // init object var model = new CatalogBasicSalaryModel(); // check id if (id > 0) { var result = CatalogBasicSalaryController.GetById(id); if (result != null) { model = result; } } // set catalog props txtName.Text = model.Name; txtDescription.Text = model.Description; txtValue.Text = ((decimal)model.Value).ToString(CultureInfo.InvariantCulture); dfAppliedDate.SetValue(model.AppliedDate); txtOrder.Text = model.Order.ToString(); hdfStatus.Text = ((int)model.Status).ToString(); cboStatus.Text = model.Status.Description(); // show window wdSetting.Show(); } } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục lương cơ bản - InitWindow", ex)); } }
/// <summary> /// Insert or Update Catalog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertOrUpdate(object sender, DirectEventArgs e) { try { // init model var model = new CatalogAllowanceModel { EditedBy = CurrentUser.User.UserName }; // check id if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0) { var result = CatalogAllowanceController.GetById(Convert.ToInt32(hdfId.Text));; if (result != null) { model = result; } } // validate form if (string.IsNullOrEmpty(hdfValueType.Text) || string.IsNullOrEmpty(hdfValueType.Text)) { Dialog.ShowError("Bạn chưa nhập đủ dữ liệu"); return; } // set new props for model model.Code = hdfType.Text; model.Name = txtName.Text; model.Description = txtDescription.Text; model.Value = !string.IsNullOrEmpty(txtValue.Text) ? Convert.ToDecimal(txtValue.Text) : 0; model.Formula = txtFormula.Text; model.ValueType = (AllowanceValueType)Convert.ToInt32(hdfValueType.Text); model.Type = hdfType.Text; model.Group = hdfGroup.Text; model.Order = !string.IsNullOrEmpty(txtOrder.Text) ? Convert.ToInt32(txtOrder.Text) : 0; model.Status = !string.IsNullOrEmpty(hdfStatus.Text) ? (CatalogStatus)Convert.ToInt32(hdfStatus.Text) : CatalogStatus.Active; // check model id if (model.Id > 0) { // update var result = CatalogAllowanceController.Update(model); if (result != null) { // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục phụ cấp", SystemAction.Edit, "Sửa danh mục {0}".FormatWith(model.Name))); } else { // show error Dialog.ShowError("Có lỗi xảy ra trong quá trình xử lý"); } } else { // set created user model.CreatedBy = CurrentUser.User.UserName; // insert var result = CatalogAllowanceController.Create(model); if (result != null) { // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục phụ cấp", SystemAction.Create, "Tạo danh mục {0}".FormatWith(model.Name))); } else { // show error Dialog.ShowError("Có lỗi xảy ra trong quá trình xử lý"); } } // hide window wdSetting.Hide(); // reload data gpCatalog.Reload(); } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục phụ cấp - InserOrUpdate", ex)); } }
/// <summary> /// Init setting window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InitWindow(object sender, DirectEventArgs e) { try { // init id var param = e.ExtraParams["Id"]; // parse id if (int.TryParse(param, out var id)) { // init window props if (id > 0) { // edit wdSetting.Title = @"Sửa"; wdSetting.Icon = Icon.Pencil; } else { // insert wdSetting.Title = @"Thêm mới"; wdSetting.Icon = Icon.Add; } // init id hdfId.Text = id.ToString(); // init object var model = new MenuModel(null); // check id if (id > 0) { var result = MenuController.GetById(id); if (result != null) { model = result; } } // set props txtMenuName.Text = model.MenuName; txtTabName.Text = model.TabName; txtIcon.Text = model.Icon; txtLinkUrl.Text = model.LinkUrl; hdfParentId.Text = model.ParentId.ToString(); cboParent.Text = model.ParentName; hdfGroup.Text = hdfFilterGroup.Text; cboGroup.Text = cboFilterGroup.Text; txtOrder.Text = model.Order.ToString(); hdfStatus.Text = ((int)model.Status).ToString(); cboStatus.Text = model.StatusName; // reset link url cboReport.Text = ""; cboFilter.Text = ""; // show window wdSetting.Show(); } } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục quản trị - InitWindow", ex)); } }
/// <summary> /// Insert or Update Catalog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertOrUpdate(object sender, DirectEventArgs e) { try { // init model var model = new CatalogModel(hdfObjName.Text) { EditedBy = CurrentUser.User.UserName }; // check id if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0) { var result = CatalogController.GetById(hdfObjName.Text, Convert.ToInt32(hdfId.Text)); if (result != null) { model = result; } } // set new props for model model.Name = txtName.Text; model.Description = txtDescription.Text; model.Order = !string.IsNullOrEmpty(txtOrder.Text) ? Convert.ToInt32(txtOrder.Text) : 0; model.Group = hdfGroup.Text; if (Enum.TryParse(hdfStatus.Text, false, out CatalogStatus status)) { model.Status = status; } // if cat group is record status if (hdfCatalogGroup.Text == nameof(RecordStatus).ToLower()) { if (Enum.TryParse(hdfGroup.Text, false, out RecordStatus group)) { model.Group = ((int)group).ToString(); } } // create result model CatalogModel resultModel; // check model id if (model.Id > 0) { // update resultModel = CatalogController.Update(hdfObjName.Text, model); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục {0}".FormatWith(hdfObjName.Text), SystemAction.Edit, "Sửa danh mục {0}".FormatWith(model.Name))); } else { // set created user model.CreatedBy = CurrentUser.User.UserName; // insert resultModel = CatalogController.Create(hdfObjName.Text, model); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục {0}".FormatWith(hdfObjName.Text), SystemAction.Create, "Tạo danh mục {0}".FormatWith(model.Name))); } // show notification if (resultModel != null) { Dialog.ShowNotification("Lưu thành công"); // hide window wdSetting.Hide(); // reload data gpCatalog.Reload(); } else { Dialog.ShowNotification("Lưu không thành công, Tên đã tồn tại"); } } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục {0} - InsertOrUpdate".FormatWith(hdfObjName.Text), ex)); } }
/// <summary> /// /// </summary> /// <param name="scheduler"></param> private void RunScheduler(Scheduler scheduler) { try { // next run time DateTime?nextRunTime = null; if (scheduler.NextRunTime == null) { return; } // switch repeat type switch (scheduler.RepeatType) { case SchedulerRepeatType.OneTime: break; case SchedulerRepeatType.Monthly: nextRunTime = scheduler.NextRunTime.Value.AddMonths(1); break; case SchedulerRepeatType.Weekly: nextRunTime = scheduler.NextRunTime.Value.AddDays(7); break; case SchedulerRepeatType.Daily: nextRunTime = scheduler.NextRunTime.Value.AddDays(1); break; case SchedulerRepeatType.Hourly: nextRunTime = scheduler.NextRunTime.Value.AddHours(1); break; case SchedulerRepeatType.IntervalTime: if (scheduler.IntervalTime > 0) { nextRunTime = scheduler.NextRunTime.Value.AddMinutes(scheduler.IntervalTime); } break; default: return; } // expired time DateTime?expiredTime = null; if (scheduler.ExpiredAfter > 0 && scheduler.RepeatType != SchedulerRepeatType.OneTime) { expiredTime = scheduler.NextRunTime.Value.AddMinutes(scheduler.ExpiredAfter); } // update current scheduler status to running SchedulerServices.Update(scheduler.Id, SchedulerStatus.Running, DateTime.Now, nextRunTime, expiredTime); // init scheduler type var schedulerType = cat_BaseServices.GetById("cat_SchedulerType", scheduler.SchedulerTypeId); // init job type var jobType = Type.GetType("Web.Core.Framework.{0},Web.Core.Framework".FormatWith(schedulerType.Name)); if (jobType == null) { return; } // init job var job = Activator.CreateInstance(jobType); // int job property ((BaseTask)job).Id = scheduler.Id; ((BaseTask)job).Name = scheduler.Name; ((BaseTask)job).Arguments = scheduler.Arguments; // execute job ((BaseTask)job).Excute(scheduler.Arguments); } catch (ThreadAbortException) { // do nothing } catch (Exception ex) { // log error SystemLogController.Create(new SystemLogModel("system", "RunScheduler", SystemAction.TrackError, SystemLogType.ScheduleError, ex.Message, ex.ToString(), true)); } finally { // update scheduler status when complete SchedulerServices.Update(scheduler.Id, scheduler.RepeatType == SchedulerRepeatType.OneTime ? SchedulerStatus.Completed : SchedulerStatus.Ready); } }
/// <summary> /// Insert or Update Catalog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertOrUpdate(object sender, DirectEventArgs e) { try { // init model var model = new CatalogGroupQuantumGradeModel { EditedBy = CurrentUser.User.UserName }; // check id if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0) { var result = CatalogGroupQuantumGradeController.GetById(Convert.ToInt32(hdfId.Text));; if (result != null) { model = result; } } // get group quantum var groupQuantum = CatalogGroupQuantumController.GetById(Convert.ToInt32(hdfGroupQuantumId.Text)); // check group quantum if (groupQuantum == null) { // show alert Dialog.ShowError("Chưa chọn nhóm ngạch"); return; } // set new props for model model.GroupQuantumId = groupQuantum.Id; model.MonthStep = !string.IsNullOrEmpty(txtMonthStep.Text) && Convert.ToInt32(txtMonthStep.Text) > 0 ? Convert.ToInt32(txtMonthStep.Text) : groupQuantum.MonthStep; model.Grade = !string.IsNullOrEmpty(txtGrade.Text) && Convert.ToInt32(txtGrade.Text) > 0 ? Convert.ToInt32(txtGrade.Text) : groupQuantum.GradeMax; model.Factor = !string.IsNullOrEmpty(txtFactor.Text) ? Convert.ToDecimal(txtFactor.Text) : 0; model.Status = !string.IsNullOrEmpty(hdfStatus.Text) ? (CatalogStatus)Convert.ToInt32(hdfStatus.Text) : CatalogStatus.Active; // check max grade if (model.Grade > groupQuantum.GradeMax) { // show alert Dialog.ShowError("Vượt quá bậc tối đa của nhóm ngạch"); return; } // check model id if (model.Id > 0) { // update CatalogGroupQuantumGradeController.Update(model); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục mức lương nhóm ngạch", SystemAction.Edit, "Sửa danh mục {0}".FormatWith(model.Name))); } else { // set created user model.CreatedBy = CurrentUser.User.UserName; // insert CatalogGroupQuantumGradeController.Create(model); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục mức lương nhóm ngạch", SystemAction.Create, "Tạo danh mục {0}".FormatWith(model.Name))); } // hide window wdSetting.Hide(); // reload data gpCatalog.Reload(); } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục mức lương nhóm ngạch - InserOrUpdate", ex)); } }
/// <summary> /// Insert or Update Catalog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertOrUpdate(object sender, DirectEventArgs e) { try { // init model var model = new CatalogBasicSalaryModel { EditedBy = CurrentUser.User.UserName }; // check id if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0) { var result = CatalogBasicSalaryController.GetById(Convert.ToInt32(hdfId.Text));; if (result != null) { model = result; } } // set new props for model model.Name = txtName.Text; model.Description = txtDescription.Text; model.Order = !string.IsNullOrEmpty(txtOrder.Text) ? Convert.ToInt32(txtOrder.Text) : 0; model.Status = !string.IsNullOrEmpty(hdfStatus.Text) ? (CatalogStatus)Convert.ToInt32(hdfStatus.Text) : CatalogStatus.Active; model.Value = Convert.ToDecimal(txtValue.Text); if (dfAppliedDate.SelectedDate != DateTime.MinValue) { model.AppliedDate = dfAppliedDate.SelectedDate; } // check model id if (model.Id > 0) { // update CatalogBasicSalaryController.Update(model); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Lương cơ bản", SystemAction.Edit, "Sửa lương cơ bản {0}".FormatWith(model.Name))); } else { // set created user model.CreatedBy = CurrentUser.User.UserName; // insert CatalogBasicSalaryController.Create(model); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Lương cơ bản", SystemAction.Create, "Thêm lương cơ bản {0}".FormatWith(model.Name))); } // hide window wdSetting.Hide(); // reload data gpCatalog.Reload(); } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục lương cơ bản - InsertOrUpdate", ex)); } }
/// <summary> /// Insert or Update Catalog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertOrUpdate(object sender, DirectEventArgs e) { try { // init model var model = new CatalogGroupQuantumModel { EditedBy = CurrentUser.User.UserName }; // check id if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0) { var result = CatalogGroupQuantumController.GetById(Convert.ToInt32(hdfId.Text));; if (result != null) { model = result; } } // set new props for model model.Name = txtName.Text; model.Description = txtDescription.Text; model.GradeMax = !string.IsNullOrEmpty(txtGradeMax.Text) && Convert.ToInt32(txtGradeMax.Text) > 0 ? Convert.ToInt32(txtGradeMax.Text) : 36; model.MonthStep = !string.IsNullOrEmpty(txtMonthStep.Text) && Convert.ToInt32(txtMonthStep.Text) > 0 ? Convert.ToInt32(txtMonthStep.Text) : 0; model.PercentageOverGrade = !string.IsNullOrEmpty(txtPercentageOverGrade.Text) && Convert.ToDecimal(txtPercentageOverGrade.Text) > 0 ? Convert.ToDecimal(txtPercentageOverGrade.Text) : 5; model.PercentageOverGradeStep = !string.IsNullOrEmpty(txtPercentageOverGradeStep.Text) && Convert.ToDecimal(txtPercentageOverGradeStep.Text) > 0 ? Convert.ToDecimal(txtPercentageOverGradeStep.Text) : 1; model.Group = hdfGroup.Text; model.Order = !string.IsNullOrEmpty(txtOrder.Text) ? Convert.ToInt32(txtOrder.Text) : 0; model.Status = !string.IsNullOrEmpty(hdfStatus.Text) ? (CatalogStatus)Convert.ToInt32(hdfStatus.Text) : CatalogStatus.Active; // check model id if (model.Id > 0) { // update CatalogGroupQuantumController.Update(model); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục nhóm ngạch", SystemAction.Edit, "Sửa danh mục {0}".FormatWith(model.Name))); } else { // set created user model.CreatedBy = CurrentUser.User.UserName; // insert CatalogGroupQuantumController.Create(model); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục nhóm ngạch", SystemAction.Create, "Tạo danh mục {0}".FormatWith(model.Name))); } // hide window wdSetting.Hide(); // reload data gpCatalog.Reload(); } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục nhóm ngạch - InserOrUpdate", ex)); } }
/// <summary> /// Insert or Update Catalog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertOrUpdate(object sender, DirectEventArgs e) { try { // init entity var model = new MenuModel() { EditedBy = CurrentUser.User.UserName }; // check id if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0) { var result = MenuController.GetById(Convert.ToInt32(hdfId.Text));; if (result != null) { model = result; } } // set new props for entity model.MenuName = txtMenuName.Text; model.TabName = txtTabName.Text; model.Icon = txtIcon.Text; model.LinkUrl = txtLinkUrl.Text; model.ParentId = string.IsNullOrEmpty(hdfParentId.Text) ? 0 : Convert.ToInt32(hdfParentId.Text); model.Order = string.IsNullOrEmpty(txtOrder.Text) ? 0 : Convert.ToInt32(txtOrder.Text); model.Group = (MenuGroup)Convert.ToInt32(hdfGroup.Text); model.Status = (MenuStatus)Convert.ToInt32(hdfStatus.Text); // check entity id if (model.Id > 0) { // update MenuController.Update(model); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục quản trị", SystemAction.Edit, "Sửa menu {0}".FormatWith(model.MenuName))); } else { // set created user model.CreatedBy = CurrentUser.User.UserName; // insert MenuController.Create(model); // log action SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục quản trị", SystemAction.Create, "Tạo menu {0}".FormatWith(model.MenuName))); } // hide window wdSetting.Hide(); // reload data gpMenu.Reload(); } catch (Exception ex) { // show dilog Dialog.ShowError(ex); // log exception SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục quản trị - InsertOrUpdate", ex)); } }