Example #1
0
        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)
            {
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        private void gửiMailBáoKhôngPhùHợpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string subject;
            string to;
            string content;

            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load dữ liệu..."))
            {
                int           id          = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                ModulesModel  product     = (ModulesModel)ModulesBO.Instance.FindByAttribute("Code", grvData.GetFocusedRowCellValue(colModuleCode).ToString())[0];
                string        productCode = product.Code;
                string        projectCode = TextUtils.ToString(grvData.GetFocusedRowCellValue(colProjectCode));
                List <string> listEmail   = getListMail(productCode);

                subject = string.Format("INVALID REPORT - {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.Count > 0 ? TextUtils.ToString(dtProjectUser.Rows[0][1]) : "";

                DataTable dtConfig = TextUtils.Select("select KeyValue from [ConfigSystem] where [KeyName]='KPH_To_TK_Email'");
                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);
                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)
            {
                MisMatchModel errorModel = (MisMatchModel)MisMatchBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)));
                errorModel.ConfirmSendMailKCS = Global.AppFullName + " - " + Environment.MachineName + " đã gửi mail vào ngày: " + DateTime.Now;
                MisMatchBO.Instance.Update(errorModel);
                loadGrid();
            }
        }
Example #4
0
        private void gửiMailKhiĐãKhắcPhụcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                MisMatchModel misMatchModel = (MisMatchModel)MisMatchBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)));
                if (misMatchModel.StatusTK == 0)
                {
                    MessageBox.Show("Vấn đề này chưa được khắc phục!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }
                ModulesModel product = (ModulesModel)ModulesBO.Instance.FindByAttribute("Code", misMatchModel.ModuleCode)[0];

                frmSendEmailAttach frm = new frmSendEmailAttach();
                frm.To = "*****@*****.**";
                frm.CC = //"*****@*****.**";
                         "[email protected];[email protected];[email protected];[email protected];";
                frm.Subject = string.Format("INVALID REPORT - {0} - {1} - Đã khắc phục", misMatchModel.Code, product.Code);
                DataTable dtConfig = TextUtils.Select("select KeyValue from [ConfigSystem] where [KeyName]='TK_To_KCS_KphEmail'");
                string    content  = dtConfig.Rows[0][0].ToString();
                frm.Content = content.Replace("<ErrorCode>", "<b>" + misMatchModel.Code + "</b>")
                              .Replace("<ProjectCode>", "<b>" + misMatchModel.ProjectCode + "</b>")
                              .Replace("<ProductCode>", "<b>" + product.Code + "</b>")
                              .Replace("<ProductName>", product.Name)
                              .Replace("<ErrorStatus>", "<b>Đã khắc phục</b>")
                              .Replace("<Description>", grvData.GetFocusedRowCellValue(colDes).ToString());
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    misMatchModel.ConfirmSendMailTK = Global.AppFullName + " - " + Environment.MachineName + " đã gửi mail vào ngày: " + DateTime.Now;
                    MisMatchBO.Instance.Update(misMatchModel);
                    loadGrid();

                    if (Global.DepartmentID == 1)//phong thiet ke
                    {
                        DataTable dt = TextUtils.Select("select * from ModuleVersion where MisMatchCode = '" + misMatchModel.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  = misMatchModel.ProjectCode;
                                    model.ModuleCode   = product.Code;
                                    model.MisMatchCode = misMatchModel.Code;
                                    model.Version      = TextUtils.ToInt(Path.GetFileName(path));
                                    model.Path         = path;
                                    model.Description  = frm.Description;
                                    model.Reason       = "Sửa không phù hợp: " + misMatchModel.Code;
                                    ModuleVersionBO.Instance.Insert(model);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("Lỗi: " + ex.Message);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #5
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (grvProject.Rows.Count == 0)
            {
                MessageBox.Show("Không có thông tin dự án dự án!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            else
            {
                string pCode = TextUtils.ToString(grvProject.Rows[0].Cells[0].Value);
                if (pCode == " ")
                {
                    MessageBox.Show("Không có thông tin dự án dự án!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }
            }

            if (grvModule.Rows.Count == 0)
            {
                MessageBox.Show("Không tồn tại module trong tổng hợp thiết kế!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            int count = 0;

            foreach (DataGridViewRow itemRow in grvModule.Rows)
            {
                if (TextUtils.ToBoolean(itemRow.Cells[colCheck.Index].EditedFormattedValue))
                {
                    count++;
                }
            }

            if (count == 0)
            {
                MessageBox.Show("Không có module nào được chọn!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            List <string> listProject = new List <string>();

            foreach (DataGridViewRow itemRow in grvProject.Rows)
            {
                listProject.Add(itemRow.Cells[colPCode.Index].Value.ToString());
            }

            string mailContent = "";

            mailContent = ((ConfigSystemModel)ConfigSystemBO.Instance.FindByAttribute("KeyName", "MailTHTK")[0]).KeyValue;
            mailContent = mailContent.Replace("<Project>", listProject[0]);
            mailContent = mailContent.Replace("<HangMuc>", _muc + " - " + _productName);

            string listModules = "";
            string moduleItem  = ((ConfigSystemModel)ConfigSystemBO.Instance.FindByAttribute("KeyName", "MailTHTK.Item")[0]).KeyValue;
            int    stt         = 0;

            foreach (DataGridViewRow itemRow in grvModule.Rows)
            {
                if (!TextUtils.ToBoolean(itemRow.Cells[colCheck.Index].EditedFormattedValue))
                {
                    continue;
                }
                stt++;
                string moduleCode = TextUtils.ToString(itemRow.Cells[colModuleCode.Index].Value);
                listModules += moduleItem.Replace("<STT>", stt.ToString())
                               .Replace("<ModuleCode>", moduleCode)
                               .Replace("<ModuleName>", itemRow.Cells[colModuleName.Index].Value.ToString());

                DataTable dtItems = LibQLSX.Select("select ID from vDesignSummaryItem where ProjectCode = '" + listProject[0] + "' and Code = '" + moduleCode + "'");
                foreach (DataRow r in dtItems.Rows)
                {
                    int id = TextUtils.ToInt(r["ID"]);
                    TPA.Model.DesignSummaryItemModel m = (TPA.Model.DesignSummaryItemModel)TPA.Business.DesignSummaryItemBO.Instance.FindByPK(id);
                    m.IsTHTK = 1;
                    TPA.Business.DesignSummaryItemBO.Instance.Update(m);
                }
            }

            mailContent = mailContent.Replace("<listModule>", listModules);

            frmSendEmailAttach frm = new frmSendEmailAttach();

            frm.Content = mailContent;
            frm.To      = "*****@*****.**";
            frm.CC      = //"*****@*****.**";
                          "[email protected];[email protected];[email protected];[email protected];[email protected];";
            frm.Subject = "(" + string.Join(", ", listProject.ToArray()) + ") - " + Path.GetFileNameWithoutExtension(txtDMVTPath.Text);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát", "Đang tạo phiên bản thiết kế"))
                {
                    DocUtils.InitFTPQLSX();
                    //Tạo version cho module
                    foreach (DataGridViewRow itemRow in grvModule.Rows)
                    {
                        if (!TextUtils.ToBoolean(itemRow.Cells[colCheck.Index].EditedFormattedValue))
                        {
                            continue;
                        }
                        try
                        {
                            string moduleCode = itemRow.Cells[colModuleCode.Index].Value.ToString();
                            string ftpPathCk  = string.Format("/Thietke.Ck/{0}/{1}.Ck", moduleCode.Substring(0, 6), moduleCode);

                            DataTable dt = TextUtils.Select("select * from ModuleVersion where ModuleCode = '" + moduleCode + "'");
                            if (dt.Rows.Count == 0)
                            {
                                if (DocUtils.CheckExits(ftpPathCk))
                                {
                                    string path = TextUtils.DownloadAll(moduleCode);

                                    ModuleVersionModel model = new ModuleVersionModel();
                                    model.ModuleCode  = moduleCode;
                                    model.ProjectCode = listProject[0];
                                    model.Version     = 0;
                                    model.Path        = path;
                                    model.Description = "Tạo phiên bản đầu tiên của module";
                                    model.Reason      = "Tạo phiên bản đầu tiên của module";
                                    ModuleVersionBO.Instance.Insert(model);
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            this.Close();
        }
Example #6
0
        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)
            {
            }
        }
Example #7
0
        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();
            }
        }
Example #8
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                return;
            }

            listProject = new List <string>();
            string hangmuc = "";

            foreach (DataGridViewRow itemRow in grvProject.Rows)
            {
                if (!TextUtils.ToBoolean(itemRow.Cells[colCheck.Index].EditedFormattedValue))
                {
                    continue;
                }
                listProject.Add(itemRow.Cells[colProjectCode.Index].Value.ToString());
                hangmuc += loadProduct(itemRow.Cells[colProjectCode.Index].Value.ToString());
            }

            string projectString = string.Join(", ", listProject.ToArray());

            string mailContent = "Gửi BP Dự án! <br>"
                                 + "Thiết kế <b>" + Module.Code + " </b>vừa được update lại dự án: <br>"
                                 + hangmuc
                                 + "<br>Đề nghị Dự án vào xác nhận và YCVT!<br>";

            frmSendEmailAttach frm = new frmSendEmailAttach();

            frm.Content = mailContent;
            frm.To      = //"*****@*****.**";
                          "[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];";
            frm.Subject = "(" + projectString + ") - Update " + Module.Code;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                #region Update Version
                //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 moduleCode = Module.Code;
                //        string ftpPathCk = string.Format("/Thietke.Ck/{0}/{1}.Ck", moduleCode.Substring(0, 6), moduleCode);
                //        string path = "";
                //        if (DocUtils.CheckExits(ftpPathCk))
                //        {
                //            path = TextUtils.DownloadAll(moduleCode);
                //        }
                //        if (path != "")
                //        {
                //            foreach (string projectCode in listProject)
                //            {
                //                ModuleVersionModel model = new ModuleVersionModel();
                //                model.ProjectCode = projectCode;
                //                model.ModuleCode = moduleCode;
                //                model.Version = TextUtils.ToInt(Path.GetFileName(path));
                //                model.Path = path;
                //                model.Description = frm.Description;
                //                model.Reason = frm.Description;
                //                ModuleVersionBO.Instance.Insert(model);
                //            }
                //        }
                //    }
                //    catch (Exception ex)
                //    {
                //        TextUtils.ShowError(ex);
                //        return;
                //    }
                //}
                #endregion

                #region Update MaterialModuleLink
                try
                {
                    int id = Module.ID;
                    if (id == 0)
                    {
                        return;
                    }

                    using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo danh mục vật tư..."))
                    {
                        string _serverPathCK = string.Format("Thietke.Ck/{0}/{1}.Ck/VT.{1}.xlsm",
                                                             Module.Code.Substring(0, 6), Module.Code);
                        DocUtils.InitFTPQLSX();
                        if (DocUtils.CheckExits(_serverPathCK))
                        {
                            DocUtils.DownloadFile("D:/", "VT." + Module.Code + ".xlsm", _serverPathCK);
                            DataTable dtDMVT = TextUtils.ExcelToDatatableNoHeader("D:/VT." + Module.Code + ".xlsm", "DMVT");
                            TextUtils.AddDMVTfromModule("D:/VT." + Module.Code + ".xlsm");
                            File.Delete("D:/VT." + Module.Code + ".xlsm");
                        }
                    }

                    MessageBox.Show("Cập nhật danh mục vật tư thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    MessageBox.Show("Cập nhật danh mục vật tư không thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                #endregion
            }
            this.Close();
        }