コード例 #1
0
        private void btnUpdateDMVT_Click(object sender, EventArgs e)
        {
            try
            {
                int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                if (id == 0)
                {
                    return;
                }
                ModulesModel model = (ModulesModel)ModulesBO.Instance.FindByPK(id);
                if (model.Status != 2)
                {
                    MessageBox.Show("Module chưa có trên nguồn chuẩn!");
                    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",
                                                         model.Code.Substring(0, 6), model.Code);
                    DocUtils.InitFTPQLSX();
                    if (DocUtils.CheckExits(_serverPathCK))
                    {
                        DocUtils.DownloadFile("D:/", "VT." + model.Code + ".xlsm", _serverPathCK);
                        DataTable dtDMVT = TextUtils.ExcelToDatatableNoHeader("D:/VT." + model.Code + ".xlsm", "DMVT");
                        TextUtils.AddDMVTfromModule("D:/VT." + model.Code + ".xlsm");
                        File.Delete("D:/VT." + model.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);
            }
        }
コード例 #2
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();
        }