private void btnKCS_XacNhan_Click(object sender, EventArgs e) { int count = 0; if (MessageBox.Show("Bạn có chắc muốn xác nhận những lỗi này đã được khắc phục?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _rownIndex = grvData.FocusedRowHandle; foreach (int i in grvData.GetSelectedRows()) { if (i < 0) { continue; } int iD = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); ModuleErrorModel model = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(iD); if (model.StatusTK == 1) { model.Status = 1; model.CompleteTimeKCS = TextUtils.GetSystemDate(); ModuleErrorBO.Instance.Update(model); count++; } } } if (count > 0) { loadGrid(); } }
private void btnConfirmTemp_Click(object sender, EventArgs e) { int count = 0; if (MessageBox.Show("Bạn có chắc muốn xác nhận tạm thời bỏ qua những lỗi này?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _rownIndex = grvData.FocusedRowHandle; foreach (int i in grvData.GetSelectedRows()) { if (i < 0) { continue; } int iD = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); ModuleErrorModel model = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(iD); if (model.ConfirmTemp == 0) { model.ConfirmTemp = 1; ModuleErrorBO.Instance.Update(model); count++; } } } if (count > 0) { loadGrid(); } }
private void btnDelete_Click(object sender, EventArgs e) { if (grvData.FocusedRowHandle < 0) { return; } ModuleErrorModel model = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID))); if (model.CreatedBy != Global.LoginName) { MessageBox.Show("Bạn không có quyền xóa lỗi này!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (TextUtils.ToInt(grvData.GetFocusedRowCellValue(colConfirmManager)) == 1) { MessageBox.Show("Bạn không thể xóa lỗi [" + grvData.GetFocusedRowCellValue(colCode).ToString() + "] vì lỗi đã được xác nhận bởi trưởng bộ phận.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (TextUtils.ToInt(grvData.GetFocusedRowCellValue(colStatusTK)) == 1) { MessageBox.Show("Bạn không thể xóa lỗi [" + grvData.GetFocusedRowCellValue(colCode).ToString() + "] vì lỗi đã được xác nhận.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } DialogResult result = MessageBox.Show("Bạn có chắc muốn xóa lỗi [" + grvData.GetFocusedRowCellValue(colCode).ToString() + "] ?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { ModuleErrorBO.Instance.Delete(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID))); loadGrid(); } }
private void toolStripButton1_Click(object sender, EventArgs e) { int count = 0; DataTable dt = TextUtils.ExcelToDatatable(@"D:\\123.xlsx", "Sheet1"); DataTable tblLink = TextUtils.Select("exec spGetModuleOfProject"); foreach (DataRow item in dt.Rows) { try { string code = item[0].ToString(); ModuleErrorModel error = (ModuleErrorModel)ModuleErrorBO.Instance.FindByAttribute("Code", code)[0]; if (error.ProjectCode != "") { continue; } string projectText = item["F3"].ToString(); ModulesModel module = (ModulesModel)ModulesBO.Instance.FindByPK(error.ModuleID); DataRow[] dt1 = tblLink.Select("ProjectCode like '%" + projectText + "%' and ProductCode = '" + module.Code + "'"); if (dt1.Length > 0) { error.ProjectCode = dt1[0]["ProjectCode"].ToString(); ModuleErrorBO.Instance.Update(error); count++; } } catch (Exception) { } } MessageBox.Show(count + " OK"); }
private void kCSHủyXácNhậnToolStripMenuItem_Click(object sender, EventArgs e) { int count = 0; _rownIndex = grvData.FocusedRowHandle; foreach (int i in grvData.GetSelectedRows()) { if (i < 0) { continue; } int iD = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); ModuleErrorModel model = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(iD); if (model.Status == 1) { model.Status = 0; model.CompleteTimeKCS = TextUtils.GetSystemDate(); ModuleErrorBO.Instance.Update(model); count++; } } if (count > 0) { loadGrid(); } }
private void btnEdit_Click(object sender, EventArgs e) { if (grvData.FocusedRowHandle < 0) { return; } ModuleErrorModel model = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID))); if (model.CreatedBy != Global.LoginName) { MessageBox.Show("Bạn không có quyền sửa lỗi này!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (model.StatusTK == 1) { MessageBox.Show("Bạn không thể sửa lỗi này.\nDo lỗi này đã được thiết kế xác nhận.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } frmBCLError frm = new frmBCLError(); frm.ErrorModel = model; _rownIndex = grvData.FocusedRowHandle; if (frm.ShowDialog() == DialogResult.OK) { loadGrid(); } }
private void huỷChoPhépDownloadTàiLiệuToolStripMenuItem_Click(object sender, EventArgs e) { int count = 0; if (MessageBox.Show("Bạn có chắc muốn huỷ cho phép download tài liệu liên quan đến lỗi này?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _rownIndex = grvData.FocusedRowHandle; foreach (int i in grvData.GetSelectedRows()) { if (i < 0) { continue; } int iD = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); ModuleErrorModel model = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(iD); if (model.IsDownloaded == 1) { model.IsDownloaded = 0; ModuleErrorBO.Instance.Update(model); count++; } } } if (count > 0) { loadGrid(); } }
private void gửiMailThôngBáoGiảiPhápTạmThờiToolStripMenuItem_Click(object sender, EventArgs e) { try { ModuleErrorModel errorModel = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID))); ModulesModel product = (ModulesModel)ModulesBO.Instance.FindByPK(errorModel.ModuleID); frmSendEmailAttach frm = new frmSendEmailAttach(); frm.To = "*****@*****.**"; //frm.CC = "*****@*****.**"; frm.CC = "[email protected];[email protected];[email protected];[email protected];"; frm.Subject = string.Format("ERROR REPORT - {0} - {1} - Khắc phục tạm thời", errorModel.Code, product.Code); DataTable dtConfig = TextUtils.Select("select KeyValue from [ConfigSystem] where [KeyName]='TKToKCS_Email'"); string content = dtConfig.Rows[0][0].ToString(); frm.Content = content.Replace("<ErrorCode>", "<b>" + errorModel.Code + "</b>") .Replace("<ProjectCode>", "<b>" + errorModel.ProjectCode + "</b>") .Replace("<ProductCode>", "<b>" + product.Code + "</b>") .Replace("<ProductName>", product.Name) .Replace("<ErrorStatus>", "<b>Khắc phục tạm thời</b>") .Replace("<ErrorUser>", grvData.GetFocusedRowCellValue(colErrorUser).ToString()) .Replace("<TamThoi>", errorModel.HuongKhacPhucTamThoi) .Replace("<LauDai>", errorModel.HuongKhacPhuc == "" ? "Chưa có" : errorModel.HuongKhacPhuc) .Replace("<Description>", errorModel.Description); if (frm.ShowDialog() == DialogResult.OK) { errorModel.ReceiveMailContent = Global.AppFullName + " - " + Environment.MachineName + " đã gửi mail vào ngày: " + DateTime.Now; ModuleErrorBO.Instance.Update(errorModel); loadGrid(); } } catch (Exception) { } }
void sendKcsMail() { int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); ModulesModel product = (ModulesModel)ModulesBO.Instance.FindByAttribute("Code", grvData.GetFocusedRowCellValue(colModule).ToString())[0]; string productCode = product.Code; string projectCode = grvData.GetFocusedRowCellValue(colProjectCode).ToString(); List <string> listEmail = getListMail(productCode); #region Mở outlook //int count = Process.GetProcesses().Where(o => o.ProcessName.Contains("OUTLOOK")).Count(); //if (count == 0) //{ // try // { // Process.Start("outlook.exe"); // } // catch (Exception) // { // } //} #endregion Mở outlook string subject = string.Format("Không phù hợp - {0} - {1}", grvData.GetFocusedRowCellValue(colCode).ToString(), productCode); DataTable dtProjectUser = LibQLSX.Select("SELECT p.ProjectCode, u.UserName FROM Project p INNER JOIN Users u ON p.UserId = u.UserId where p.ProjectCode='" + projectCode + "'"); string projectUser = dtProjectUser.Rows[0][1] != null ? dtProjectUser.Rows[0][1].ToString() : ""; DataTable dtConfig = TextUtils.Select("select KeyValue from [ConfigSystem] where [KeyName]='KPH_To_TK_Email'"); string content = dtConfig.Rows[0][0].ToString(); content = content.Replace("<ErrorCode>", "<b>" + grvData.GetFocusedRowCellValue(colCode).ToString() + "</b>") .Replace("<ProjectCode>", "<b>" + projectCode + "</b>") .Replace("<ProjectUser>", "<b>" + projectUser == "" ? "Không tìm thấy" : projectUser + "</b>") .Replace("<ProductCode>", "<b>" + productCode + "</b>") .Replace("<ProductName>", product.Name) .Replace("<UserFind>", grvData.GetFocusedRowCellValue(colUserFindText).ToString()) .Replace("<Description>", grvData.GetFocusedRowCellValue(colDes).ToString()) .Replace("<Ck>", NVCoKhi == "" ? "Không tìm thấy" : NVCoKhi) .Replace("<Dn>", NVDien == "" ? "Không tìm thấy" : NVDien) .Replace("<Dt>", NVDT == "" ? "Không tìm thấy" : NVDT); string to = ""; foreach (string item in listEmail) { to += item.ToLower() + ";"; } frmSendEmailAttach frm = new frmSendEmailAttach(); frm.Subject = subject; frm.CC = //"*****@*****.**"; "[email protected];[email protected];[email protected];[email protected];"; frm.To = to; frm.Content = content; if (frm.ShowDialog() == DialogResult.OK) { ModuleErrorModel errorModel = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID))); errorModel.CreateMailContent = Global.AppFullName + " đã gửi mail vào ngày: " + DateTime.Now; ModuleErrorBO.Instance.Update(errorModel); } }
private void xemẢnhLỗiToolStripMenuItem_Click(object sender, EventArgs e) { ModuleErrorModel model = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID))); frmBCLError frm = new frmBCLError(1); frm.ErrorModel = model; frm.Show(); }
private void btnConfirmManager_Click(object sender, EventArgs e) { string createdby = TextUtils.ToString(grvData.GetFocusedRowCellValue(colCreatedBy)); int departmentCurrent = Global.DepartmentID; ArrayList userArray = UsersBO.Instance.FindByAttribute("LoginName", createdby); UsersModel user = new UsersModel(); if (userArray != null) { if (userArray.Count > 0) { user = (UsersModel)userArray[0]; } } if (departmentCurrent != user.DepartmentID) { MessageBox.Show("Bạn không có quyền xác nhận lỗi này?", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } int count = 0; if (MessageBox.Show("Bạn có chắc muốn xác nhận những lỗi này là đúng?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _rownIndex = grvData.FocusedRowHandle; foreach (int i in grvData.GetSelectedRows()) { if (i < 0) { continue; } int iD = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); ModuleErrorModel model = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(iD); if (model.ConfirmManager == 0) { model.ConfirmManager = 1; ModuleErrorBO.Instance.Update(model); count++; sendKcsMail(i); } } if (count > 0) { //MessageBox.Show("Trưởng bộ phận xác nhận lỗi thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); loadGrid(); } } }
private void gửiMailToolStripMenuItem_Click(object sender, EventArgs e) { ModuleErrorModel model = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID))); if (model.CreatedBy != Global.LoginName) { MessageBox.Show("Bạn không có quyền gửi mail báo lỗi này!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (model.ConfirmManager == 0) { MessageBox.Show("Lỗi này chưa được trưởng bộ phận xác nhận!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } sendKcsMail(); }
void UpdateLoi() { List <string> listErrorCode = new List <string>(); for (int i = 0; i < grvData.RowCount; i++) { if (i == 0) { continue; } if (grvData.GetRowCellValue(i, "F1") == null) { continue; } string code = grvData.GetRowCellValue(i, "F1").ToString(); if (code == "") { continue; } try { ModuleErrorModel errror = (ModuleErrorModel)ModuleErrorBO.Instance.FindByAttribute("Code", code)[0]; errror.Status = TextUtils.ToInt(grvData.GetRowCellValue(i, "F2").ToString().ToLower() == "ok" ? 1 : 0); //errror.StatusTK = TextUtils.ToInt(grvData.GetRowCellValue(i, "F20").ToString().ToLower() == "ok" ? 1 : 0); if (errror.Status == 1) { ModuleErrorBO.Instance.Update(errror); } } catch (Exception) { listErrorCode.Add(code); } } string path = "D:\\Debug.txt"; foreach (string item in listErrorCode) { File.AppendAllText(path, item + Environment.NewLine); } MessageBox.Show("Thành công!"); }
private void btnSave_Click1(object sender, EventArgs e) { dt.Rows.RemoveAt(0); dt.Rows.RemoveAt(0); foreach (DataRow r in dt.Rows) { int moduleID = 0; try { ArrayList listModule = ModulesBO.Instance.FindByAttribute("Code", r["F5"].ToString().Trim()); moduleID = ((ModulesModel)listModule[0]).ID; } catch (Exception) { } if (moduleID == 0) { continue; } int userID = 0; try { ArrayList listUser = UsersBO.Instance.FindByAttribute("LoginName", r["F81"].ToString().Trim()); userID = ((UsersModel)listUser[0]).ID; } catch (Exception) { } int tq = 0; try { ArrayList listType = ModuleErrorTypeBO.Instance.FindByAttribute("Name", r["F131"].ToString().Trim()); tq = ((ModuleErrorTypeModel)listType[0]).ID; } catch (Exception) { } int nn = 0; try { ArrayList listType = ModuleErrorTypeBO.Instance.FindByAttribute("Name", r["F141"].ToString().Trim()); nn = ((ModuleErrorTypeModel)listType[0]).ID; } catch (Exception) { } ModuleErrorModel error = new ModuleErrorModel(); error.Code = r["F1"].ToString().Trim(); error.Author = r["F81"].ToString().Trim().Replace(" ", ""); error.Description = r["F6"].ToString().Trim(); error.HuongKhacPhuc = r["F151"].ToString().Trim(); error.ModuleID = moduleID; error.PLLTQ = tq; error.PLLCP = 0; error.PLLNN = nn; error.Status = r["F111"].ToString().Trim().ToLower() == "ok" ? 1 : 0; error.UserID = userID; ModuleErrorBO.Instance.Insert(error); } MessageBox.Show("Thêm lỗi thành công!"); }
protected ModuleErrorFacade(ModuleErrorModel model) : base(model) { }
/// <summary> /// Thêm ảnh lỗi cho các thiết kế /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button9_Click(object sender, EventArgs e) { DocUtils.InitFTPTK(); string path = "D:/ErrorTree"; string[] listModulePath = Directory.GetDirectories(path); foreach (string modulePath in listModulePath) { string moduleCode = Path.GetFileName(modulePath); ModulesModel thisModule = (ModulesModel)ModulesBO.Instance.FindByExpression(new Expression("Code", moduleCode))[0]; string[] listErrorPath = Directory.GetDirectories(modulePath); foreach (string errorPath in listErrorPath) { string errorCode = Path.GetFileName(errorPath); DataTable dtError = TextUtils.Select("ModuleError", new Expression("Code", errorCode)); ModuleErrorModel thisError; if (dtError.Rows.Count > 0) { thisError = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(TextUtils.ToInt(dtError.Rows[0]["ID"])); } else { thisError = new ModuleErrorModel(); thisError.ModuleID = thisModule.ID; thisError.Code = errorCode; thisError.Status = 0; thisError.Description = "Chưa khai báo"; thisError.Author = Global.AppUserName; thisError.UserID = Global.UserID; ModuleErrorBO.Instance.Insert(thisError); } foreach (string errorFilePath in Directory.GetFiles(errorPath)) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { FileInfo fInfo = new FileInfo(errorFilePath); ModuleErrorImageModel errorImageModel = new ModuleErrorImageModel(); errorImageModel.DateCreated = TextUtils.GetSystemDate(); errorImageModel.FileName = Path.GetFileName(errorFilePath); errorImageModel.Size = fInfo.Length; errorImageModel.FilePath = "Modules\\ErrorImage\\" + errorImageModel.FileName; errorImageModel.ModuleErrorID = thisError.ID; errorImageModel.ID = (int)pt.Insert(errorImageModel); DocUtils.UploadFile(errorFilePath, "Modules\\ErrorImage"); pt.CommitTransaction(); } catch (Exception) { } finally { pt.CloseConnection(); } } } } MessageBox.Show("OK"); }
void save(bool close) { bool isNew = false; ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (!ValidateForm()) { return; } if (ErrorModel.ID > 0) { ErrorModel = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(ErrorModel.ID); } ErrorModel.Code = txtCode.Text.Trim().ToUpper(); ErrorModel.Description = txtDescription.Text.Trim(); ErrorModel.PLLTQ = cboLoiTrucQuan.EditValue != null?TextUtils.ToInt(cboLoiTrucQuan.EditValue) : 0; ErrorModel.Status = cboStatus.SelectedIndex; ErrorModel.ProjectCode = TextUtils.ToString(cboProject.EditValue); //ErrorModel.ModuleID = cboModule.EditValue != null ? ((ModulesModel)ModulesBO.Instance.FindByAttribute("Code", cboModule.EditValue.ToString())[0]).ID : 0; ErrorModel.ModuleID = TextUtils.ToInt(cboModule.EditValue); ErrorModel.UserFindID = TextUtils.ToInt(cboUser.EditValue); ErrorModel.DepartmentID = TextUtils.ToInt(cboBPgayloi.SelectedValue); //ErrorModel.DepartmentKPID = TextUtils.ToInt(cboBPkhacphuc.SelectedValue); ErrorModel.CompleteTimeKCS = _completeTimeKCS; //if (ErrorModel.DepartmentID == 1)//phong thiet ke //{ ErrorModel.ConfirmManager = 0; //} if (ErrorModel.ID == 0) { ErrorModel.CreatedDate = TextUtils.GetSystemDate(); ErrorModel.CreatedBy = Global.AppUserName; ErrorModel.UpdatedDate = ErrorModel.CreatedDate; ErrorModel.UpdatedBy = Global.AppUserName; ErrorModel.ID = (int)pt.Insert(ErrorModel); isNew = true; } else { ErrorModel.UpdatedDate = TextUtils.GetSystemDate(); ErrorModel.UpdatedBy = Global.AppUserName; pt.Update(ErrorModel); isNew = false; } pt.CommitTransaction(); _isSaved = true; //if (isNew) //{ //if ((MessageBox.Show("Bạn có muốn gửi mail đến bộ phận liên quan?",TextUtils.Caption,MessageBoxButtons.YesNo,MessageBoxIcon.Question)) // == DialogResult.Yes) //{ // using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang gửi mail...")) // { //sendMail(); // } //} //} if (close) { this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Lưu trữ 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(); } }
void sendKcsMail(int index) { string subject = ""; string content = ""; string to = ""; using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load dữ liệu...")) { int id = TextUtils.ToInt(grvData.GetRowCellValue(index, colID)); string departmentCodeGL = grvData.GetRowCellValue(index, colDepartmentCodeGL).ToString(); string departmentMailGL = ""; try { departmentMailGL = ((DepartmentModel)DepartmentBO.Instance.FindByAttribute("Code", departmentCodeGL)[0]).Email; } catch { //departmentMailGL = "*****@*****.**"; departmentMailGL = "[email protected];[email protected];[email protected];[email protected];"; } ModulesModel product = (ModulesModel)ModulesBO.Instance.FindByAttribute("Code", grvData.GetRowCellValue(index, colModuleCode).ToString())[0]; string productCode = product.Code; string projectCode = TextUtils.ToString(grvData.GetRowCellValue(index, colProjectCode)); List <string> listEmail = getListMail(productCode); #region Mở outlook int count = Process.GetProcesses().Where(o => o.ProcessName.Contains("OUTLOOK")).Count(); if (count == 0) { try { Process.Start("outlook.exe"); } catch (Exception) { } } #endregion Mở outlook subject = string.Format("ERROR REPORT - {0} - {1}", TextUtils.ToString(grvData.GetRowCellValue(index, colCode)), productCode); DataTable dtProjectUser = LibQLSX.Select("SELECT p.ProjectCode, u.UserName FROM Project p INNER JOIN Users u ON p.UserId = u.UserId where p.ProjectCode='" + projectCode + "'"); string projectUser = dtProjectUser.Rows.Count > 0 ? TextUtils.ToString(dtProjectUser.Rows[0][1]) : ""; DataTable dtConfig = TextUtils.Select("select KeyValue from [ConfigSystem] where [KeyName]='KcsToTK_Email'"); content = dtConfig.Rows[0][0].ToString(); content = content.Replace("<ErrorCode>", "<b>" + grvData.GetRowCellValue(index, colCode).ToString() + "</b>") .Replace("<ProjectCode>", "<b>" + projectCode + "</b>") .Replace("<ProjectUser>", "<b>" + projectUser == "" ? "Không tìm thấy" : projectUser + "</b>") .Replace("<ProductCode>", "<b>" + productCode + "</b>") .Replace("<ProductName>", product.Name) .Replace("<UserFind>", grvData.GetRowCellValue(index, colUserFind) == null ? "Không tìm thấy" : grvData.GetRowCellValue(index, colUserFind).ToString()) .Replace("<TQ>", grvData.GetRowCellValue(index, colTQ) == null ? "Không tìm thấy" : grvData.GetRowCellValue(index, colTQ).ToString()) .Replace("<Description>", grvData.GetRowCellValue(index, colDes).ToString()) .Replace("<Ck>", NVCoKhi == "" ? "Không tìm thấy" : NVCoKhi) .Replace("<Dn>", NVDien == "" ? "Không tìm thấy" : NVDien) .Replace("<Dt>", NVDT == "" ? "Không tìm thấy" : NVDT); if (departmentCodeGL == "TK")//Phong TK { foreach (string item in listEmail) { to += item.ToLower() + ";"; } } else { to = departmentMailGL; } } frmSendEmailAttach frm = new frmSendEmailAttach(); frm.Subject = subject; //frm.CC = "*****@*****.**"; frm.To = to; frm.Content = content; if (frm.ShowDialog() == DialogResult.OK) { ModuleErrorModel errorModel = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetRowCellValue(index, colID))); errorModel.CreateMailContent = Global.AppFullName + " - " + Environment.MachineName + " đã gửi mail vào ngày: " + DateTime.Now; ModuleErrorBO.Instance.Update(errorModel); loadGrid(); } }
private void btnSave_Click(object sender, EventArgs e) { for (int i = 1; i < grvData.RowCount; i++) { try { if (grvData.GetRowCellValue(i, "1") == null) { continue; } string code = grvData.GetRowCellValue(i, "1").ToString(); if (code == "") { continue; } DepartmentModel department = null; DepartmentModel departmentKP = null; UsersModel userFind = null; try { department = (DepartmentModel)DepartmentBO.Instance.FindByAttribute("Code", grvData.GetRowCellValue(i, "7").ToString())[0]; } catch { } try { departmentKP = (DepartmentModel)DepartmentBO.Instance.FindByAttribute("Code", grvData.GetRowCellValue(i, "10").ToString())[0]; } catch { } try { userFind = (UsersModel)UsersBO.Instance.FindByAttribute("LoginName", grvData.GetRowCellValue(i, "16").ToString())[0]; } catch { } ModulesModel module = null; string moduleCode = ""; try { moduleCode = grvData.GetRowCellValue(i, "5").ToString(); module = (ModulesModel)ModulesBO.Instance.FindByAttribute("Code", grvData.GetRowCellValue(i, "5").ToString().Substring(0, 10))[0]; } catch { } ModuleErrorModel error; if (!ModuleErrorBO.Instance.CheckExist("Code", code)) { error = new ModuleErrorModel(); } else { error = (ModuleErrorModel)ModuleErrorBO.Instance.FindByAttribute("Code", code)[0]; } //error.Description = moduleCode.Length == 10 ? grvData.GetRowCellValue(i, "6").ToString() : moduleCode + ": " // + grvData.GetRowCellValue(i, "6").ToString(); //error.HuongKhacPhucTamThoi = grvData.GetRowCellValue(i, "9").ToString(); //error.Status = grvData.GetRowCellValue(i, "12").ToString().Trim().ToLower() == "ok" ? 1 : 0; //error.StatusTK = grvData.GetRowCellValue(i, "12").ToString().Trim().ToLower() == "ok" ? 1 : 0; //error.DepartmentID = department == null ? 0 : department.ID; //error.DepartmentKPID = departmentKP == null ? 0 : departmentKP.ID; //error.Reason = grvData.GetRowCellValue(i, "8") == null ? "" : grvData.GetRowCellValue(i, "8").ToString(); //error.UserFindID = userFind == null ? 0 : userFind.ID; //error.CreatedBy = "thao.nv"; error.UpdatedDate = TextUtils.ToDate(grvData.GetRowCellValue(i, "2").ToString()); error.CreatedDate = TextUtils.ToDate(grvData.GetRowCellValue(i, "2").ToString()); error.CompleteTimeTK = TextUtils.ToDate(grvData.GetRowCellValue(i, "11").ToString()); if (error.ID == 0) { error.Code = code; error.ModuleID = module == null ? 0 : module.ID; ModuleErrorBO.Instance.Insert(error); } else { ModuleErrorBO.Instance.Update(error); } } catch (Exception) { } } MessageBox.Show("Thêm lỗi thành công!"); }
void save(bool close) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (!ValidateForm()) { return; } if (ErrorModel.ID > 0) { ErrorModel = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(ErrorModel.ID); } ErrorModel.StatusTK = cboStatus.SelectedIndex; ErrorModel.PLLCP = cboLoiChiPhi.SelectedValue != null?TextUtils.ToInt(cboLoiChiPhi.SelectedValue) : 0; ErrorModel.Reason = txtReason.Text.Trim(); ErrorModel.IsTK = 1; ErrorModel.DepartmentKPID = TextUtils.ToInt(cboBPkhacphuc.SelectedValue); ErrorModel.HuongKhacPhucTamThoi = txtHuongKhacPhucTamThoi.Text.Trim(); ErrorModel.HuongKhacPhuc = txtHuongKhacPhuc.Text.Trim(); ErrorModel.CompleteTimeTK = cboStatus.SelectedIndex == 0 ? (DateTime?)null : DateTime.Now; ErrorModel.StartTimeDK = (DateTime?)dateEditStartDK.EditValue; ErrorModel.StartTimeTT = (DateTime?)dateEditStartTT.EditValue; ErrorModel.EndTimeDK = (DateTime?)dateEditEndDK.EditValue; ErrorModel.EndTimeTT = (DateTime?)dateEditEndTT.EditValue; ErrorModel.Note = txtNote.Text.Trim(); if (ErrorModel.ID == 0) { ErrorModel.ID = (int)pt.Insert(ErrorModel); } else { ErrorModel.UpdatedDate = TextUtils.GetSystemDate(); ErrorModel.UpdatedBy = Global.AppUserName; pt.Update(ErrorModel); } pt.CommitTransaction(); _isSaved = true; if (close) { this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Lưu trữ 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(); } }
private void btnSendMailComplete_Click(object sender, EventArgs e) { try { ModuleErrorModel errorModel = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID))); if (errorModel.StatusTK == 0) { MessageBox.Show("Lỗi chưa được xác nhận là đã khắc phục!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } ModulesModel product = (ModulesModel)ModulesBO.Instance.FindByPK(errorModel.ModuleID); frmSendEmailAttach frm = new frmSendEmailAttach(); frm.To = "*****@*****.**"; //frm.CC = "*****@*****.**"; frm.CC = "[email protected];[email protected];[email protected];[email protected];"; frm.Subject = string.Format("ERROR REPORT - {0} - {1} - Đã khắc phục", errorModel.Code, product.Code); DataTable dtConfig = TextUtils.Select("select KeyValue from [ConfigSystem] where [KeyName]='TKToKCS_Email'"); string content = dtConfig.Rows[0][0].ToString(); frm.Content = content.Replace("<ErrorCode>", "<b>" + errorModel.Code + "</b>") .Replace("<ProjectCode>", "<b>" + errorModel.ProjectCode + "</b>") .Replace("<ProductCode>", "<b>" + product.Code + "</b>") .Replace("<ProductName>", product.Name) .Replace("<ErrorStatus>", "<b>Đã khắc phục</b>") .Replace("<ErrorUser>", grvData.GetFocusedRowCellValue(colErrorUser).ToString()) .Replace("<TamThoi>", errorModel.HuongKhacPhucTamThoi) .Replace("<LauDai>", errorModel.HuongKhacPhuc == "" ? "Chưa có" : errorModel.HuongKhacPhuc) .Replace("<Description>", errorModel.Description); if (frm.ShowDialog() == DialogResult.OK) { errorModel.ReceiveMailContent = Global.AppFullName + " - " + Environment.MachineName + " đã gửi mail vào ngày: " + DateTime.Now; ModuleErrorBO.Instance.Update(errorModel); loadGrid(); if (Global.DepartmentID == 1)//phong thiet ke { DataTable dt = TextUtils.Select("select * from ModuleVersion where ModuleErrorCode = '" + errorModel.Code + "'"); if (dt.Rows.Count == 0) { using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát", "Đang tạo phiên bản thiết kế")) { try { string path = TextUtils.DownloadAll(product.Code); ModuleVersionModel model = new ModuleVersionModel(); model.ProjectCode = errorModel.ProjectCode; model.ModuleCode = product.Code; model.ModuleErrorCode = errorModel.Code; model.Version = TextUtils.ToInt(Path.GetFileName(path)); model.Path = path; model.Description = frm.Description; model.Reason = "Sửa lỗi: " + errorModel.Code; ModuleVersionBO.Instance.Insert(model); } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message); } } } } } } catch (Exception) { } }
void save(bool close) { bool isNew = false; ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (!ValidateForm()) { return; } if (ErrorModel.ID > 0) { ErrorModel = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(ErrorModel.ID); } ErrorModel.Code = txtCode.Text.Trim().ToUpper(); ErrorModel.Description = txtDescription.Text.Trim(); ErrorModel.PLLTQ = cboLoiTrucQuan.EditValue != null?TextUtils.ToInt(cboLoiTrucQuan.EditValue) : 0; ErrorModel.Status = cboStatus.SelectedIndex; ErrorModel.ProjectCode = TextUtils.ToString(cboProject.EditValue); //ErrorModel.ModuleID = cboModule.EditValue != null ? ((ModulesModel)ModulesBO.Instance.FindByAttribute("Code", cboModule.EditValue.ToString())[0]).ID : 0; ErrorModel.ModuleID = TextUtils.ToInt(cboModule.EditValue); ErrorModel.UserFindID = TextUtils.ToInt(cboUser.EditValue); ErrorModel.DepartmentID = TextUtils.ToInt(cboBPgayloi.SelectedValue); //ErrorModel.DepartmentKPID = TextUtils.ToInt(cboBPkhacphuc.SelectedValue); ErrorModel.CompleteTimeKCS = _completeTimeKCS; //if (ErrorModel.DepartmentID == 1)//phong thiet ke //{ //} if (ErrorModel.DepartmentID == 6)//Phòng vật tư { ErrorModel.SupplierId = TextUtils.ToString(cboSupplier.EditValue); ErrorModel.SupplierCode = grvCboSupplier.GetFocusedRowCellValue(colSupplierCode) == null ? ErrorModel.SupplierCode : TextUtils.ToString(grvCboSupplier.GetFocusedRowCellValue(colSupplierCode)); ErrorModel.SupplierName = grvCboSupplier.GetFocusedRowCellValue(colSupplierName) == null ? ErrorModel.SupplierName : TextUtils.ToString(grvCboSupplier.GetFocusedRowCellValue(colSupplierName)); } if (ErrorModel.ID == 0) { ErrorModel.CreatedDate = TextUtils.GetSystemDate(); ErrorModel.CreatedBy = Global.AppUserName; ErrorModel.UpdatedDate = ErrorModel.CreatedDate; ErrorModel.UpdatedBy = Global.AppUserName; ErrorModel.ID = (int)pt.Insert(ErrorModel); ErrorModel.ConfirmManager = 0; isNew = true; } else { ErrorModel.UpdatedDate = TextUtils.GetSystemDate(); ErrorModel.UpdatedBy = Global.AppUserName; pt.Update(ErrorModel); isNew = false; } pt.CommitTransaction(); _isSaved = true; if (close) { this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Lưu trữ 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(); } }