private void btnSave_Click(object sender, EventArgs e) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (!ValidateForm()) { return; } if (Model == null) { Model = new ModuleGroupModel(); } Model.Name = txtName.Text.Trim().ToUpper(); Model.Code = txtCode.Text.Trim().ToUpper(); Model.Description = txtDescription.Text.Trim(); Model.ParentID = TextUtils.ToInt(leParentCat.EditValue); if (Model.ID == 0) { Model.CreatedDate = TextUtils.GetSystemDate(); Model.CreatedBy = Global.AppUserName; Model.UpdatedDate = Model.CreatedDate; Model.UpdatedBy = Global.AppUserName; Model.ID = (int)pt.Insert(Model); } else { Model.UpdatedDate = TextUtils.GetSystemDate(); Model.UpdatedBy = Global.AppUserName; pt.Update(Model); } pt.CommitTransaction(); CurentNode = Model.ID; this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } }
private void btnEditGroup_Click(object sender, EventArgs e) { try { int id = TextUtils.ToInt(treeData.FocusedNode.GetValue(colIDTree)); if (id == 0) { return; } ModuleGroupModel model = (ModuleGroupModel)ModuleGroupBO.Instance.FindByPK(id); frmModuleGroup frm = new frmModuleGroup(); frm.Model = model; if (frm.ShowDialog() == DialogResult.OK) { _curentNode = frm.CurentNode; loadTree(); } } catch (Exception) { } }
private void btnSave_Click(object sender, EventArgs e) { if (grvData.RowCount == 0) { return; } bool isSuccess = true; for (int i = 0; i < grvData.RowCount; i++) { string code = grvData.GetRowCellValue(i, colCode).ToString(); if (code == "") { continue; } string moduleFilm = grvData.GetRowCellValue(i, colFilm).ToString(); if (ModulesBO.Instance.CheckExist("Code", code)) { if (moduleFilm != "" && code.ToUpper().StartsWith("TPAD")) { string[] listFilm = moduleFilm.Replace("\n", ",").Split(','); foreach (string item in listFilm) { if (ModuleFilmBO.Instance.CheckExist("Code", code)) { continue; } ModuleFilmModel fModel = new ModuleFilmModel(); fModel.LastTimeChange = 0; fModel.LastDateChange = DateTime.Now; fModel.Code = item; fModel.ModuleID = ((ModulesModel)ModulesBO.Instance.FindByAttribute("Code", code)[0]).ID; fModel.CreatedDate = TextUtils.GetSystemDate(); fModel.CreatedBy = Global.AppUserName; fModel.UpdatedDate = fModel.CreatedDate; fModel.UpdatedBy = Global.AppUserName; ModuleFilmBO.Instance.Insert(fModel); } } continue; } ModulesModel model = new ModulesModel(); model.Code = grvData.GetRowCellValue(i, colCode).ToString(); model.Name = grvData.GetRowCellValue(i, colName).ToString(); model.Path = ""; model.Description = ""; model.Note = grvData.GetRowCellValue(i, colNote).ToString(); model.Status = TextUtils.ToInt(grvData.GetRowCellValue(i, colStatus1)); model.FileElectric = 0; model.FileElectronic = 0; model.FileMechanics = 0; try { ModuleGroupModel gmodel = new ModuleGroupModel(); if (code.ToUpper().StartsWith("TPAD")) { gmodel = (ModuleGroupModel)ModuleGroupBO.Instance.FindByAttribute("Code", code.Substring(0, 6))[0]; } else if (code.ToUpper().StartsWith("PCB")) { gmodel = (ModuleGroupModel)ModuleGroupBO.Instance.FindByAttribute("Code", code.Substring(0, 5))[0]; model.FileElectronic = 1; model.Status = 0; } else { MessageBox.Show("Nhóm module này chưa được khởi tạo.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); isSuccess = false; break; } model.ModuleGroupID = gmodel.ID; } catch (Exception) { MessageBox.Show("Nhóm module này chưa được khởi tạo.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); isSuccess = false; break; } model.CreatedDate = TextUtils.GetSystemDate(); model.CreatedBy = Global.AppUserName; model.UpdatedDate = model.CreatedDate; model.UpdatedBy = Global.AppUserName; model.ID = (int)ModulesBO.Instance.Insert(model); if (moduleFilm != "" && code.ToUpper().StartsWith("TPAD")) { string[] listFilm = moduleFilm.Replace("\n", ",").Split(','); foreach (string item in listFilm) { ModuleFilmModel fModel = new ModuleFilmModel(); fModel.LastTimeChange = 0; fModel.LastDateChange = DateTime.Now; fModel.Code = item; fModel.ModuleID = model.ID; fModel.CreatedDate = TextUtils.GetSystemDate(); fModel.CreatedBy = Global.AppUserName; fModel.UpdatedDate = fModel.CreatedDate; fModel.UpdatedBy = Global.AppUserName; ModuleFilmBO.Instance.Insert(fModel); } } } if (isSuccess) { MessageBox.Show("Lưu trữ thành công", "Thông báo"); } }
protected ModuleGroupFacade(ModuleGroupModel model) : base(model) { }
void AddModule() { ModuleGroupModel moduleGroup = (ModuleGroupModel)ModuleGroupBO.Instance.FindByAttribute("Code", cboSheet.SelectedValue.ToString())[0]; for (int i = 0; i < grvData.RowCount; i++) { bool isAdd = true; if (grvData.GetRowCellValue(i, "F3") == null) { continue; } string codeNew = grvData.GetRowCellValue(i, "F3").ToString().Trim(); if (codeNew == "") { continue; } if (!codeNew.StartsWith("TPAD.")) { continue; } DataTable dtModuleChuan = TextUtils.Select("Select * from Modules where Status = 2 and Code ='" + codeNew + "'"); if (dtModuleChuan.Rows.Count > 0) { CodeExist += codeNew + Environment.NewLine; continue; } else { DataTable dtModuleKchuan = TextUtils.Select("Select * from Modules where Status <> 2 and Code ='" + codeNew + "'"); if (dtModuleKchuan.Rows.Count > 0) { isAdd = false; } } string nameNew = grvData.GetRowCellValue(i, "F6") == null ? "" : grvData.GetRowCellValue(i, "F6").ToString(); string nameOld = grvData.GetRowCellValue(i, "F5") == null ? "" : grvData.GetRowCellValue(i, "F5").ToString(); string codeOld = grvData.GetRowCellValue(i, "F4") == null ? "" : grvData.GetRowCellValue(i, "F4").ToString(); ModulesModel module; if (isAdd) { module = new ModulesModel(); module.ModuleGroupID = moduleGroup.ID; module.Status = 0; } else { module = (ModulesModel)ModulesBO.Instance.FindByAttribute("Code", codeNew)[0]; } module.Code = codeNew; module.Name = nameNew == "" ? nameOld : nameNew; module.Note = "Mã đã có version"; module.Description = codeOld; if (isAdd) { ModulesBO.Instance.Insert(module); } else { ModulesBO.Instance.Update(module); } } MessageBox.Show(CodeExist); CodeExist = ""; }