コード例 #1
0
ファイル: frmError.cs プロジェクト: B06-0253/NVTHAO
        void sendEmail()
        {
            ModulesModel product     = (ModulesModel)ModulesBO.Instance.FindByPK(ErrorModel.ModuleID);
            string       productCode = product.Code;

            string nguoiGayLoi = "";
            string userMails   = "";

            foreach (DataGridViewRow item in grvData.Rows)
            {
                nguoiGayLoi += item.Cells[colFullName.Index].Value.ToString() + ",";
                userMails   += item.Cells[colLoginName.Index].Value.ToString() + ";";
            }

            frmSendEmailAttach frm = new frmSendEmailAttach();

            frm.To = "*****@*****.**";
            frm.CC = //"*****@*****.**";
                     "[email protected];[email protected];[email protected];[email protected];";
            frm.Subject = string.Format("ERROR REPORT - {0} - {1}", ErrorModel.Code, productCode);
            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>" + productCode + "</b>")
                          .Replace("<ProductName>", product.Name)
                          .Replace("<ErrorStatus>", "<b>" + cboStatus.Text + "</b>")
                          .Replace("<ErrorUser>", nguoiGayLoi)
                          .Replace("<TamThoi>", ErrorModel.HuongKhacPhucTamThoi)
                          .Replace("<LauDai>", ErrorModel.HuongKhacPhuc == "" ? "Chưa có" : ErrorModel.HuongKhacPhuc);
            frm.Show();
        }
コード例 #2
0
ファイル: frmBaoCaoLoi.cs プロジェクト: mrgrey88/QLTK
        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)
            {
            }
        }
コード例 #3
0
ファイル: frmMisMatchManager.cs プロジェクト: mrgrey88/QLTK
        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);
            }
        }
コード例 #4
0
ファイル: frmBCLError.cs プロジェクト: mrgrey88/QLTK
        void sendMail()
        {
            if (ErrorModel.DepartmentID == 1)//Phong TK
            {
                //ModulesModel product = (ModulesModel)ModulesBO.Instance.FindByAttribute("Code", cboModule.EditValue.ToString())[0];
                ModulesModel  product     = (ModulesModel)ModulesBO.Instance.FindByPK(TextUtils.ToInt(cboModule.EditValue));
                string        productCode = product.Code;
                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("ERROR REPORT - {0} - {1}", ErrorModel.Code, productCode);
                string content = "Mã lỗi: <b>" + ErrorModel.Code + "</b><br>"
                                 + "Mã dự án: <b>" + cboProject.EditValue.ToString() + "<b><br>"
                                 + "Mã sản phẩm: <b>" + productCode + "<b><br>"
                                 + "Tên sản phẩm: <b>" + product.Name + "<b><br>"
                                 + "Mô tả lỗi: " + ErrorModel.Description + "<br>"
                                 + "Hình ảnh lỗi: <a>" + ErrorModel.FolderPathError + "</a>" + "<br>"
                                 + "Danh sách nhân viên thiết kế: " + "<br>"
                                 + "Thiết kế cơ khí: " + NVCoKhi + "<br>"
                                 + "Thiết kế điện: " + NVDien + "<br>"
                                 + "Thiết kế điện tử: " + NVDT
                ;
                string to = "";
                foreach (string item in listEmail)
                {
                    to += item.ToLower() + ";";
                }

                frmSendEmailAttach frm = new frmSendEmailAttach();
                frm.Subject = subject;
                frm.CC      = "*****@*****.**";
                frm.To      = to;
                frm.Content = content;
                TextUtils.OpenForm(frm);
                //bool success = TextUtils.SetEmailSend(subject, content, to.Substring(0, to.Length - 1), "*****@*****.**");
                //if (!success)
                //{
                //    TextUtils.SetEmailSend(subject, content, "*****@*****.**", "");
                //}
            }
        }
コード例 #5
0
ファイル: frmMisMatchManager.cs プロジェクト: mrgrey88/QLTK
        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();
            }
        }
コード例 #6
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            string folderPath       = "";
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                folderPath = fbd.SelectedPath;
            }
            else
            {
                return;
            }

            string fullName = TextUtils.ToString(grvCboUser.GetFocusedRowCellValue(colFullName));

            TextUtils.ExportExcel(grvData, folderPath, fullName, false);
            string filepath = folderPath + "//" + fullName + ".xls";

            DataTable dtFile = new DataTable();

            dtFile.Columns.Add("ID");
            dtFile.Columns.Add("FileName");
            dtFile.Columns.Add("Path");

            dtFile.Rows.Add(0, Path.GetFileName(filepath), filepath);

            string             content = " Dear " + fullName + "!<br>" + "Phòng dự án gửi anh/chị các vấn đề mà anh/chị phụ trách.<br> Đề nghị anh/chị thực hiện theo đúng kế hoạch.<br>Xin chân thành cảm ơn.";
            string             subject = "VẤN ĐỀ TỒN ĐỌNG DỰ ÁN";
            frmSendEmailAttach frm     = new frmSendEmailAttach();

            frm.To       = TextUtils.ToString(grvCboUser.GetFocusedRowCellValue(colAccount)) + "@tpa.com.vn";
            frm.Content  = content;
            frm.Subject  = subject;
            frm.dtFile   = dtFile;
            frm.IsClosed = true;
            frm.CC       = "[email protected];[email protected];[email protected];[email protected];[email protected]";
            TextUtils.OpenForm(frm);
        }
コード例 #7
0
ファイル: frmMisMatchManager.cs プロジェクト: mrgrey88/QLTK
        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)
            {
            }
        }
コード例 #8
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();
        }
コード例 #9
0
ファイル: frmBaoCaoLoi.cs プロジェクト: mrgrey88/QLTK
        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)
            {
            }
        }
コード例 #10
0
ファイル: frmBaoCaoLoi.cs プロジェクト: mrgrey88/QLTK
        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();
            }
        }
コード例 #11
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();
        }
コード例 #12
0
        private void btnExcel_Click(object sender, EventArgs e)
        {
            if (grvData.RowCount == 0)
            {
                return;
            }

            string localPath        = "";
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                localPath = fbd.SelectedPath + "\\ProjectReport_ " + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + ".xlsx";
            }
            else
            {
                return;
            }

            string filePath = Application.StartupPath + "\\Templates\\PhongSXLR\\ProjectReport.xlsx";

            try
            {
                File.Copy(filePath, localPath, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: File excel đang được mở." + Environment.NewLine + ex.Message);
                return;
            }

            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo FCM..."))
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                Excel.Application app       = default(Excel.Application);
                Excel.Workbook    workBoook = default(Excel.Workbook);
                Excel.Worksheet   workSheet = default(Excel.Worksheet);
                try
                {
                    app = new Excel.Application();
                    app.Workbooks.Open(localPath);
                    workBoook = app.Workbooks[1];
                    workSheet = (Excel.Worksheet)workBoook.Worksheets[1];

                    for (int i = grvData.RowCount - 1; i >= 0; i--)
                    {
                        workSheet.Cells[3, 1] = i + 1;
                        workSheet.Cells[3, 2] = TextUtils.ToString(grvData.GetRowCellValue(i, colName));
                        workSheet.Cells[3, 3] = TextUtils.ToString(grvData.GetRowCellValue(i, colCode));
                        workSheet.Cells[3, 4] = TextUtils.ToDecimal(grvData.GetRowCellDisplayText(i, colCompletePercent));
                        workSheet.Cells[3, 5] = TextUtils.ToDecimal(grvData.GetRowCellDisplayText(i, colCNC));
                        workSheet.Cells[3, 6] = TextUtils.ToDecimal(grvData.GetRowCellDisplayText(i, colIN));
                        workSheet.Cells[3, 7] = TextUtils.ToDecimal(grvData.GetRowCellDisplayText(i, colGCAL));
                        workSheet.Cells[3, 8] = TextUtils.ToDecimal(grvData.GetRowCellDisplayText(i, colPCB));
                        workSheet.Cells[3, 9] = TextUtils.ToDecimal(grvData.GetRowCellDisplayText(i, colLR));
                        ((Excel.Range)workSheet.Rows[3]).Insert();
                    }

                    ((Excel.Range)workSheet.Rows[2]).Delete();
                    ((Excel.Range)workSheet.Rows[2]).Delete();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (app != null)
                    {
                        app.ActiveWorkbook.Save();
                        app.Workbooks.Close();
                        app.Quit();
                    }
                }

                //Process.Start(localPath);
                DataTable dtFile = new DataTable();

                dtFile.Columns.Add("ID");
                dtFile.Columns.Add("FileName");
                dtFile.Columns.Add("Path");

                dtFile.Rows.Add(0, Path.GetFileName(localPath), localPath);

                frmSendEmailAttach frm = new frmSendEmailAttach();
                frm.dtFile  = dtFile;
                frm.Content = "Hi all!<br>SXLR gửi báo cáo tiến độ sản xuất ngày " + DateTime.Now.ToString("dd-MM-yyyy")
                              + ".<br>Vui lòng xem trong attach file.<br>Để rõ chi tiết từng dự án, vui lòng xem trên phần mềm QLTK: PHÒNG SXLR/Báo cáo tiến độ/Báo cáo tiến độ theo thiết bị.";
                frm.To      = "[email protected];[email protected];[email protected];[email protected];[email protected]";
                frm.Subject = "Báo cáo tiến độ sản xuất đến ngày: " + DateTime.Now.ToString("dd-MM-yyyy");
                frm.Show();
            }
        }