private void btnCreateVersion_Click(object sender, EventArgs e) { int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); if (id == 0) { return; } BaiThucHanhModel BaiThucHanh = (BaiThucHanhModel)BaiThucHanhBO.Instance.FindByPK(id); DialogResult result = MessageBox.Show("Bạn có chắc muốn tạo phiên bản cho bài thực hành [" + BaiThucHanh.Name + "] ?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } string reason = ""; frmVersionReason frm = new frmVersionReason(); if (frm.ShowDialog() == DialogResult.OK) { reason = frm.Reason; } else { return; } CreateVersion(BaiThucHanh, reason); loadGrid(true); }
private void xemChiTiếtToolStripMenuItem_Click(object sender, EventArgs e) { int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colObjectID)); if (id == 0) { return; } if (BaiThucHanh.ID > 0) { BaiThucHanhModel model = (BaiThucHanhModel)BaiThucHanhBO.Instance.FindByPK(id); int version = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colVersion)); frmBaiTHDetail frm = new frmBaiTHDetail(); frm.BaiThucHanh = model; frm.IsShowVersion = true; frm.Version = version; TextUtils.OpenForm(frm); } else { ProductsModel model = (ProductsModel)ProductsBO.Instance.FindByPK(id); int version = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colVersion)); frmProduct frm = new frmProduct(); frm.Product = model; frm.IsShowVersion = true; frm.Version = version; TextUtils.OpenForm(frm); } }
private void btnShowPrice_Click(object sender, EventArgs e) { int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); if (id == 0) { return; } BaiThucHanhModel model = (BaiThucHanhModel)BaiThucHanhBO.Instance.FindByPK(id); frmBaiThucHanhPrice frm = new frmBaiThucHanhPrice(); frm.BaiThucHanh = model; TextUtils.OpenForm(frm); }
void CreateVersion(BaiThucHanhModel BaiThucHanh) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { // Tạo phiên bản bài thực hành BaiThucHanhVersionModel versionModel = new BaiThucHanhVersionModel(); versionModel.BaiThucHanhID = BaiThucHanh.ID; versionModel.Reason = "Tạo phiên bản đầu tiên"; versionModel.Version = BaiThucHanh.Version; versionModel.ID = (int)pt.Insert(versionModel); //Tạo các phiên bản module bài thực hành ArrayList lisModules = BaiThucHanhModuleBO.Instance.FindByAttribute("BaiThucHanhID", BaiThucHanh.ID); if (lisModules.Count > 0) { foreach (var item in lisModules) { BaiThucHanhModuleModel thisModule = (BaiThucHanhModuleModel)item; BaiThucHanhModuleVersionModel moduleVersion = new BaiThucHanhModuleVersionModel(); moduleVersion.BTHVersionID = versionModel.ID; moduleVersion.Code = thisModule.Code; moduleVersion.CVersion = thisModule.CVersion; moduleVersion.Hang = thisModule.Hang; moduleVersion.Name = thisModule.Name; moduleVersion.Qty = thisModule.Qty; moduleVersion.Type = thisModule.Type; moduleVersion.ID = (int)pt.Insert(moduleVersion); } } pt.CommitTransaction(); } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } }
private void btnEdit_Click(object sender, EventArgs e) { int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); if (id == 0) { return; } BaiThucHanhModel model = (BaiThucHanhModel)BaiThucHanhBO.Instance.FindByPK(id); _rownIndex = grvData.FocusedRowHandle; frmBaiTHDetail frm = new frmBaiTHDetail(); frm.BaiThucHanh = model; if (frm.ShowDialog() == DialogResult.OK) { loadGrid(true); } }
protected BaiThucHanhFacade(BaiThucHanhModel model) : base(model) { }
void CreateVersion(BaiThucHanhModel BaiThucHanh, string reason) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { #region Tạo phiên bản bài thực hành BaiThucHanhVersionModel versionModel = new BaiThucHanhVersionModel(); versionModel.BaiThucHanhID = BaiThucHanh.ID; versionModel.Reason = reason; versionModel.Version = BaiThucHanh.Version + 1; versionModel.ID = (int)pt.Insert(versionModel); #endregion #region Tạo các phiên bản module bài thực hành ArrayList lisModules = BaiThucHanhModuleBO.Instance.FindByAttribute("BaiThucHanhID", BaiThucHanh.ID); if (lisModules.Count > 0) { foreach (var item in lisModules) { BaiThucHanhModuleModel thisModule = (BaiThucHanhModuleModel)item; BaiThucHanhModuleVersionModel moduleVersion = new BaiThucHanhModuleVersionModel(); moduleVersion.BTHVersionID = versionModel.ID; moduleVersion.Code = thisModule.Code; moduleVersion.CVersion = thisModule.CVersion; moduleVersion.Hang = thisModule.Hang; moduleVersion.Name = thisModule.Name; moduleVersion.Qty = thisModule.Qty; moduleVersion.Type = thisModule.Type; moduleVersion.ID = (int)pt.Insert(moduleVersion); } } #endregion #region Tạo phiên bản các file List <string> listFilePath = new List <string>(); ArrayList listFiles = BaiThucHanhFileBO.Instance.FindByExpression(new Expression("BaiThucHanhID", BaiThucHanh.ID) .And(new Expression("Version", BaiThucHanh.Version))); string ftpFolderPath = "BieuMau\\BaiThucHanh\\" + BaiThucHanh.Code + "\\" + versionModel.Version; if (!DocUtils.CheckExits(Path.GetDirectoryName(ftpFolderPath))) { DocUtils.MakeDir(Path.GetDirectoryName(ftpFolderPath)); } foreach (var item in listFiles) { BaiThucHanhFileModel thisFile = (BaiThucHanhFileModel)item; string path = Path.GetTempPath(); DocUtils.DownloadFile(path, Path.GetFileName(thisFile.Path), thisFile.Path); BaiThucHanhFileModel file = new BaiThucHanhFileModel(); file.BaiThucHanhID = BaiThucHanh.ID; file.Name = thisFile.Name; file.Length = thisFile.Length; file.LocalPath = path + "\\" + Path.GetFileName(thisFile.Path); file.Path = ftpFolderPath + "\\" + file.Name; file.Version = versionModel.Version; pt.Insert(file); listFilePath.Add(path + "\\" + Path.GetFileName(thisFile.Path)); } #endregion BaiThucHanh.Version += 1; pt.Update(BaiThucHanh); pt.CommitTransaction(); foreach (string filePath in listFilePath) { if (!DocUtils.CheckExits(ftpFolderPath)) { DocUtils.MakeDir(ftpFolderPath); } DocUtils.UploadFile(filePath, ftpFolderPath); } MessageBox.Show("Tạo phiên bản bài thực hành thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } }