Ejemplo n.º 1
0
        bool ValidateForm()
        {
            if (grvProject.Rows.Count == 0)
            {
                MessageBox.Show("Không tồn tại dự án cho thiết kế này!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            int count = 0;

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

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

            return(true);
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (cboUserGroup.SelectedIndex < 0)
            {
                return;
            }
            int userGroupID = TextUtils.ToInt(cboUserGroup.SelectedValue);
            int catID       = TextUtils.ToInt(treeData.FocusedNode.GetValue(colIDTree));

            if (catID == 0)
            {
                return;
            }
            grvData.FocusedRowHandle = -1;

            List <int> lstPerID = new List <int>();

            for (int i = 0; i < grvData.RowCount; i++)
            {
                bool isRole = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsHasRole));
                if (isRole)
                {
                    lstPerID.Add(TextUtils.ToInt(grvData.GetRowCellValue(i, colID)));
                }
            }

            TextUtils.ExcuteProcedure("spAddPermissionToGroupRole",
                                      new string[] { "@UserGroupID", "@FormAndFunctionGroupID", "@ListPermissionID" },
                                      new object[] { userGroupID, catID, lstPerID.Count > 0 ? string.Join(";", lstPerID) : "" });

            MessageBox.Show("Phân quyền thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 3
0
 private void grvYCVT_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
 {
     if (e.Column == colRcheck && _active)
     {
         bool   check       = TextUtils.ToBoolean(grvYCVT.GetFocusedRowCellValue(colRcheck));
         string requestCode = TextUtils.ToString(grvYCVT.GetFocusedRowCellValue(colRCode));
         if (check)
         {
             addRequestItem(requestCode);
         }
         else
         {
             DataRow[] drs = dtRI.Select("RequestCode <> '" + requestCode + "'");
             if (drs.Length > 0)
             {
                 dtRI = drs.CopyToDataTable();
             }
             else
             {
                 dtRI.Rows.Clear();
                 chkRAll.Checked = false;
             }
             grdParts.DataSource = dtRI;
         }
     }
 }
Ejemplo n.º 4
0
 private void grvYCMVT_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
 {
     if (e.Column == colCheck)
     {
         bool   check     = TextUtils.ToBoolean(grvYCMVT.GetFocusedRowCellValue(colCheck));
         string YCMVTCode = TextUtils.ToString(grvYCMVT.GetFocusedRowCellValue(colCodeYC));
         if (check)
         {
             addItem(YCMVTCode);
         }
         else
         {
             DataRow[] drs = _dtItem.Select("ProposalCode <> '" + YCMVTCode + "'");
             if (drs.Length > 0)
             {
                 _dtItem = drs.CopyToDataTable();
             }
             else
             {
                 _dtItem.Rows.Clear();
                 //chkRAll.Checked = false;
             }
             grdData.DataSource = _dtItem;
         }
         //grvData.FocusedRowHandle = -1;
     }
 }
Ejemplo n.º 5
0
 private void grvProject_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
 {
     if (e.Column == colCheck)
     {
         bool   check     = TextUtils.ToBoolean(grvProject.GetFocusedRowCellValue(colCheck));
         string projectId = TextUtils.ToString(grvProject.GetFocusedRowCellValue(colPProjectId));
         if (check)
         {
             addItem(projectId);
         }
         else
         {
             DataRow[] drs = _dtProjectProblem.Select("ProjectId <> '" + projectId + "'");
             if (drs.Length > 0)
             {
                 _dtProjectProblem = drs.CopyToDataTable();
             }
             else
             {
                 _dtProjectProblem.Rows.Clear();
             }
             grdData.DataSource = _dtProjectProblem;
         }
     }
 }
Ejemplo n.º 6
0
        private void grvData_CustomDrawCell_1(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            GridView View = sender as GridView;

            if (e.RowHandle >= 0)
            {
                bool status = TextUtils.ToBoolean(View.GetRowCellValue(e.RowHandle, colIsDeleted));
                if (status)// && e.Column == colName)
                {
                    e.Appearance.BackColor = Color.Yellow;
                }
            }
        }
Ejemplo n.º 7
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (grvData.SelectedRows.Count <= 0)
            {
                return;
            }
            _isAdd           = false;
            txtName.Text     = grvData.SelectedRows[0].Cells[colFileName.Name].Value.ToString();
            chkExist.Checked = TextUtils.ToBoolean(grvData.SelectedRows[0].Cells[colExist.Name].Value.ToString());
            int iD = TextUtils.ToInt(grvData.SelectedRows[0].Cells[colID.Name].Value.ToString());

            _model = (DesignStructureFileModel)DesignStructureFileBO.Instance.FindByPK(iD);
            SetInterface(true);
        }
Ejemplo n.º 8
0
        private void frmModule_Load(object sender, EventArgs e)
        {
            GridLocalizer.Active = new MyGridLocalizer();
            loadCombo();
            loadPK();

            cboHMI.SelectedIndex = 0;
            cboPLC.SelectedIndex = 0;

            if (Module.ID != 0)
            {
                txtName.Text            = Module.Name;
                txtCode.Text            = Module.Code;
                txtNote.Text            = Module.Note;
                cboStatus.SelectedIndex = Module.Status;
                leParentCat.EditValue   = Module.ModuleGroupID;
                chkCoKhi.Checked        = TextUtils.ToBoolean(Module.FileMechanics);
                chkDien.Checked         = TextUtils.ToBoolean(Module.FileElectric);
                chkDienTu.Checked       = TextUtils.ToBoolean(Module.FileElectronic);
                txtTSKT.Text            = Module.Specifications.Replace("\n", "\r\n");

                chkStop.Checked           = Module.StopStatus == 1;
                chkIsUpdatedFilm1.Checked = Module.IsUpdatedFilm == 1;

                cboHMI.SelectedIndex = Module.IsHMI;
                cboPLC.SelectedIndex = Module.IsPLC;

                btnModuleHistory.Visible = true;

                this.Text = this.Text + ": " + Module.Code + "-" + Module.Name;
                loadGridError();
                //\\SERVER\Thietke\Luutru\PHANMEM\MaterialImage\FH204 AC-25)0.03.png
                string imagePath = @"\\server\Company\Share\PHANMEM\ModuleImage\" + Module.Code + ".jpg";

                if (File.Exists(imagePath))
                {
                    pictureBox1.ImageLocation = imagePath;
                }
            }
            else
            {
                if (IsCopy)
                {
                    this.Text = this.Text + " đang COPY từ: " + Module.Code + "-" + Module.Name;
                }
                leParentCat.EditValue     = CatID;
                groupControlError.Enabled = false;
                cboStatus.SelectedIndex   = 0;
            }
        }
Ejemplo n.º 9
0
        private void grvData_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.RowHandle < 0)
            {
                return;
            }
            GridView View     = sender as GridView;
            bool     complete = TextUtils.ToBoolean(View.GetRowCellValue(e.RowHandle, colComplete));

            if (complete)
            {
                e.Appearance.BackColor = Color.GreenYellow;
            }
        }
Ejemplo n.º 10
0
        private void xemVấnĐềDựÁnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool isProblem = TextUtils.ToBoolean(treeData.FocusedNode.GetValue(colIsProjectProblem));

            if (!isProblem)
            {
                return;
            }

            frmProjectProblemManager frm = new frmProjectProblemManager();

            frm.ModuleCode  = TextUtils.ToString(treeData.FocusedNode.GetValue(colCodeTK));
            frm.ProjectCode = TextUtils.ToString(grvProject.GetFocusedRowCellValue(colProjectCode));
            frm.Show();
        }
Ejemplo n.º 11
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (!grvData.IsDataRow(grvData.FocusedRowHandle))
     {
         return;
     }
     SetInterface(true);
     _isAdd                       = false;
     txtName.Text                 = TextUtils.ToString(grvData.GetFocusedRowCellValue(colName));
     txtCode.Text                 = TextUtils.ToString(grvData.GetFocusedRowCellValue(colCode));
     txtVat.EditValue             = TextUtils.ToDecimal(grvData.GetFocusedRowCellValue(colVAT));
     txtPercentProfit.EditValue   = TextUtils.ToDecimal(grvData.GetFocusedRowCellValue(colProfitPercent));
     txtCustomerPercent.EditValue = TextUtils.ToDecimal(grvData.GetFocusedRowCellValue(colCustomerPercent));
     chkIsAfterTax.Checked        = TextUtils.ToBoolean(grvData.GetFocusedRowCellValue(colIsAfterTax));
 }
Ejemplo n.º 12
0
        private void grvData_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.RowHandle < 0)
            {
                return;
            }
            GridView View = sender as GridView;

            bool     isCompleted   = TextUtils.ToBoolean(View.GetRowCellValue(e.RowHandle, colIsCompleted));
            DateTime?completedDate = TextUtils.ToDate2(View.GetRowCellValue(e.RowHandle, colCompletedDate));

            if (completedDate == null)
            {
                return;
            }
            if (!isCompleted && completedDate.Value.Date <= DateTime.Now.Date)
            {
                e.Appearance.BackColor = Color.Yellow;
            }
        }
Ejemplo n.º 13
0
        private void grvData_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            bool    isTM    = TextUtils.ToBoolean(grvData.GetFocusedRowCellValue(colIsTM));
            decimal total   = TextUtils.ToDecimal(grvData.GetFocusedRowCellValue(colTotal));
            decimal percent = TextUtils.ToDecimal(grvData.GetFocusedRowCellValue(colPercentPay));
            int     handle  = e.RowHandle;

            if (e.Column == colPercentPay || e.Column == colTotal || e.Column == colIsTM)
            {
                decimal value = 0;
                if (total > 0)
                {
                    value = percent * total / 100;
                    if (isTM)
                    {
                        grvData.SetFocusedRowCellValue(colTM, percent * total / 100);
                        grvData.SetFocusedRowCellValue(colCK, 0);
                    }
                    else
                    {
                        grvData.SetFocusedRowCellValue(colCK, percent * total / 100);
                        grvData.SetFocusedRowCellValue(colTM, 0);
                    }
                }
                else
                {
                    if (isTM)
                    {
                        grvData.SetFocusedRowCellValue(colTM, 0);
                        grvData.SetFocusedRowCellValue(colCK, 0);
                    }
                    else
                    {
                        grvData.SetFocusedRowCellValue(colCK, 0);
                        grvData.SetFocusedRowCellValue(colTM, 0);
                    }
                }
                grvData.FocusedRowHandle = -1;
                grvData.FocusedRowHandle = handle;
            }
        }
Ejemplo n.º 14
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (grvData.DataSource == null)
                {
                    return;
                }
                int    id       = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                string code     = grvData.GetFocusedRowCellValue(colCode).ToString();
                bool   islocked = TextUtils.ToBoolean(grvData.GetFocusedRowCellValue(colIsLocked));
                if (id == 0)
                {
                    return;
                }

                if (CaseVoucherDebtBO.Instance.CheckExist("CaseID", id))
                {
                    MessageBox.Show("Vụ việc này đang chứa chứng từ nên không thể xóa được.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                if (islocked)
                {
                    MessageBox.Show("Vụ việc này đã chốt nên không thể xóa được.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                if (MessageBox.Show("Bạn có chắc muốn xóa vụ việc [" + grvData.GetFocusedRowCellValue(colName).ToString() + "] không?",
                                    TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
                CasePaidBO.Instance.Delete(id);
                loadData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (grvVL.RowCount == 0)
            {
                return;
            }
            grvVL.FocusedRowHandle = -1;

            for (int i = 0; i < grvVL.RowCount; i++)
            {
                int         id    = TextUtils.ToInt(grvVL.GetRowCellValue(i, colID));
                StuffsModel stuff = new StuffsModel();
                if (id > 0)
                {
                    stuff = (StuffsModel)StuffsBO.Instance.FindByPK(id);
                }

                stuff.Code        = TextUtils.ToString(grvVL.GetRowCellValue(i, colCode));
                stuff.Description = TextUtils.ToString(grvVL.GetRowCellValue(i, colDes));
                stuff.Price       = TextUtils.ToDecimal(grvVL.GetRowCellValue(i, colPrice));
                stuff.Hang        = TextUtils.ToString(grvVL.GetRowCellValue(i, colHang));
                stuff.TypeWeight  = TextUtils.ToBoolean(grvVL.GetRowCellValue(i, colWeight));

                if (stuff.Code == "" && stuff.Hang == "")
                {
                    continue;
                }

                if (id > 0)
                {
                    StuffsBO.Instance.Update(stuff);
                }
                else
                {
                    StuffsBO.Instance.Insert(stuff);
                }
            }
            loadStuffs();
            MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 16
0
        private void grvProject_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.Column == colPCheck)
            {
                bool   check       = TextUtils.ToBoolean(grvProject.GetFocusedRowCellValue(colPCheck));
                string projectCode = TextUtils.ToString(grvProject.GetFocusedRowCellValue(colPCode));
                if (check)
                {
                    addYCVT();
                }
                else
                {
                    DataRow[] drs = dtR.Select("ProjectCode <> '" + projectCode + "'");
                    if (drs.Length > 0)
                    {
                        dtR = drs.CopyToDataTable();
                    }
                    else
                    {
                        dtR.Rows.Clear();
                    }
                    grdYCVT.DataSource = dtR;

                    if (dtRI.Rows.Count > 0)
                    {
                        DataRow[] drsRI = dtRI.Select("ProjectCode <> '" + projectCode + "'");
                        if (drsRI.Length > 0)
                        {
                            dtRI = drsRI.CopyToDataTable();
                        }
                        else
                        {
                            dtRI.Rows.Clear();
                        }
                        grdParts.DataSource = dtRI;
                    }
                }
            }
        }
Ejemplo n.º 17
0
 private void grvData_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
 {
     if (e.RowHandle >= 0)
     {
         string code  = grvData.GetRowCellValue(e.RowHandle, "Code").ToString();
         bool   stop  = TextUtils.ToBoolean(grvData.GetRowCellValue(e.RowHandle, "StopStatus"));
         string group = grvData.GetRowCellValue(e.RowHandle, "MaterialGroupCode").ToString();
         if (code == "")
         {
             return;
         }
         //MaterialModel material = (MaterialModel)MaterialBO.Instance.FindByAttribute("Code", code)[0];
         //DataTable dt = TextUtils.Select("SELECT * FROM [vMaterial] with(nolock) where Code ='" + code + "'");
         if (stop)
         {
             e.Appearance.BackColor = Color.Yellow;
         }
         if (group == "TPAVT.Z01")
         {
             e.Appearance.BackColor = Color.Red;
         }
     }
 }
Ejemplo n.º 18
0
        private void btnChoose_Click(object sender, EventArgs e)
        {
            //Nếu đang sử dụng database thì thôi
            if (TextUtils.ToBoolean(grvData.GetFocusedRowCellValue(colIsUse)))
            {
                MessageBox.Show("Dữ liệu này đang được sử dụng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            //progressBar.Visible = true;
            //Thread.Sleep(5000);
            //progressBar.Visible = false;
            //return;
            using (WaitDialogForm fWait = new WaitDialogForm("", ""))
            {
                try
                {
                    string fileAltax = TextUtils.ToString(grvData.GetFocusedRowCellValue(colAltax));
                    string fileHyp   = TextUtils.ToString(grvData.GetFocusedRowCellValue(colHyp));
                    int    id        = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));

                    //Restore database file đã chọn vào database backup
                    string sqlRestore = $"exec spRestoreDatabase @FileNameAltax = '{fileAltax.Trim()}',@FileNameHyp='{fileHyp.Trim()}'";
                    //Update lại trạng thái database đã được sử dụng
                    string sqlUpdateIsUse = $"exec spUpdateBackupVersion {id}";

                    TextUtils.ExcuteSQL($"{sqlRestore};{sqlUpdateIsUse}");

                    loadData();

                    this.DialogResult = DialogResult.OK;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Ejemplo n.º 19
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataTable dtUserKCS = LibQLSX.Select("select top 1 * from Users where Account = '" + Global.AppUserName + "'");

            if (dtUserKCS.Rows.Count == 0)
            {
                MessageBox.Show("Tài khoản đăng nhập không có trên QLSX", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //pt.CloseConnection();
                return;
            }

            decimal OK = 0;
            decimal NG = 0;

            //ProcessTransaction pt = new ProcessTransaction();
            //pt.OpenConnection();
            //pt.BeginTransaction();

            if (!ValidateForm())
            {
                //pt.CloseConnection();
                return;
            }
            grvData.FocusedRowHandle = -1;

            try
            {
                for (int i = 0; i < grvData.RowCount; i++)
                {
                    string criteriaImportId = TextUtils.ToString(grvData.GetRowCellValue(i, colCriteriaImportId));

                    CriteriaImportModel model = new CriteriaImportModel();
                    if (criteriaImportId != "")
                    {
                        ArrayList arr = CriteriaImportBO.Instance.FindByAttribute("CriteriaImportId", criteriaImportId);
                        model = (CriteriaImportModel)arr[0];
                    }

                    model.CriteriaName         = "Đúng thông số, kích thước kỹ thuật.";
                    model.ValueRequest         = "Vật tư, thiết bị đảm bảo chất lượng.";
                    model.CriteriaIndex        = TextUtils.ToInt(grvData.GetRowCellValue(i, colSTT));
                    model.IsHalf               = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsHalf));
                    model.ProductPartsImportId = ProductPartsImport.ProductPartsImportId;

                    bool status = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colStatus));
                    model.Status = status ? 1 : 0;

                    model.ValueResult = TextUtils.ToString(grvData.GetRowCellValue(i, colValueResult));
                    //model.CriteriaIndex = TextUtils.ToInt(grvData.GetRowCellValue(i, colCriteriaImportId));

                    if (criteriaImportId != "")
                    {
                        CriteriaImportBO.Instance.UpdateQLSX(model);
                    }
                    else
                    {
                        DataTable dt = LibQLSX.Select("SELECT top 1 CriteriaImportId FROM CriteriaImport order by CriteriaImportId desc");
                        if (dt.Rows.Count > 0)
                        {
                            criteriaImportId = TextUtils.ToString(dt.Rows[0]["CriteriaImportId"]);
                            string number = criteriaImportId.Substring(2, 8);
                            criteriaImportId = "CI" + string.Format("{0:00000000}", TextUtils.ToInt(number) + 1);
                        }
                        model.CriteriaImportId = criteriaImportId;
                        CriteriaImportBO.Instance.InsertQLSX(model);
                    }
                    if (model.Status == 1)
                    {
                        OK++;
                    }
                    else
                    {
                        NG++;
                    }
                }

                ProductPartsImport.UserId  = TextUtils.ToString(dtUserKCS.Rows[0]["UserId"]);
                ProductPartsImport.TotalOK = Qty % 1 == 0 ? OK : Qty;
                ProductPartsImport.TotalNG = Qty % 1 == 0 ? NG : Qty; //NG;
                ProductPartsImportBO.Instance.UpdateQLSX(ProductPartsImport);

                //pt.CommitTransaction();

                loadGrid();

                _isSaved = true;

                MessageBox.Show("Tác vụ thành công!", TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Tác vụ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                //pt.CloseConnection();
            }

            if (_isSaved)
            {
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
        }
Ejemplo n.º 20
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();
        }
Ejemplo n.º 21
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            decimal tm = 0;
            decimal ck = 0;

            PaymentTableModel PaymentTable = new PaymentTableModel();

            PaymentTable.IsDeleted = false;
            PaymentTable.Note      = "";
            PaymentTable.Number    = loadNumber();
            //PaymentTable.TotalTM = TextUtils.ToDecimal(colTM.SummaryItem.SummaryValue);
            //PaymentTable.TotalCK = TextUtils.ToDecimal(colCK.SummaryItem.SummaryValue);
            PaymentTable.UpdatedBy   = Global.AppUserName;
            PaymentTable.UpdatedDate = DateTime.Now;
            PaymentTable.CreatedBy   = Global.AppUserName;
            PaymentTable.CreatedDate = DateTime.Now;

            PaymentTable.ID = (long)pt.Insert(PaymentTable);

            grvData.FocusedRowHandle = -1;
            for (int i = 0; i < grvData.RowCount; i++)
            {
                if (i < 0)
                {
                    continue;
                }
                bool check = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colCheck));
                if (!check)
                {
                    continue;
                }

                long iD = TextUtils.ToInt64(grvData.GetRowCellValue(i, colID));
                PaymentTableItemModel model = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(iD);

                PaymentTableModel pay = (PaymentTableModel)PaymentTableBO.Instance.FindByPK(model.PaymentTableID);
                pay.TotalTM -= model.TotalCash;
                pay.TotalCK -= model.TotalCK;
                pt.Update(pay);

                model.PaymentTableID = PaymentTable.ID;
                pt.Update(model);

                tm += model.TotalCash;
                ck += model.TotalCK;
            }

            pt.CommitTransaction();

            PaymentTable.TotalTM = tm;
            PaymentTable.TotalCK = ck;

            PaymentTableItemBO.Instance.Update(PaymentTable);

            loadItems();
        }
Ejemplo n.º 22
0
        private void btnBrowser_Click(object sender, EventArgs e)
        {
            int isApproved = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colIsApproved));

            if (isApproved == 2)
            {
                return;
            }
            if (cboUserApproved.Text == "")
            {
                MessageBox.Show("Người duyệt không được để trống", "Xác nhận", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DialogResult Approve = MessageBox.Show("Bạn có chắc chắn duyệt", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (Approve == DialogResult.No)
            {
                return;
            }
            Int32[] selectedRowHandles = grvData.GetSelectedRows();
            for (int i = 0; i < selectedRowHandles.Length; i++)
            {
                int selectedRowHandle = selectedRowHandles[i];
                if (selectedRowHandle >= 0)
                {
                    int id = TextUtils.ToInt(grvData.GetRowCellValue(selectedRowHandle, colID));
                    if (id == 0)
                    {
                        return;
                    }
                    int ProductWorkingID = TextUtils.ToInt(grvData.GetRowCellValue(selectedRowHandle, colProductWorkingID));
                    if (ProductWorkingID == 0)
                    {
                        return;
                    }
                    ProductWorkingModel      productWorking      = (ProductWorkingModel)ProductWorkingBO.Instance.FindByPK(ProductWorkingID);
                    ProductWorkingModel      productWorkings     = new ProductWorkingModel();
                    ProductWorkingAuditModel productWorkingAudit = (ProductWorkingAuditModel)ProductWorkingAuditBO.Instance.FindByPK(id);
                    isApproved = TextUtils.ToInt(grvData.GetRowCellValue(selectedRowHandle, colIsApproved));
                    if (isApproved == 2)
                    {
                        return;
                    }
                    productWorkingAudit.IsApproved   = 2;
                    productWorkingAudit.UserApproved = cboUserApproved.Text.Trim();
                    ProductWorkingAuditBO.Instance.Update(productWorkingAudit);
                    if (productWorkingAudit.ActionType == 1)
                    {
                        if (isApproved == 1)
                        {
                            productWorking.IsApproved = 2;
                            ProductWorkingBO.Instance.Update(productWorking);
                        }
                        if (isApproved == 3)
                        {
                            productWorkingAudit.IsApproved   = 2;
                            productWorkingAudit.UserApproved = cboUserApproved.Text.Trim();
                            ProductWorkingAuditBO.Instance.Update(productWorkingAudit);
                            productWorkings.ProductID       = productWorkingAudit.ProductID;
                            productWorkings.ProductStepID   = productWorkingAudit.ProductStepID;
                            productWorkings.WorkingID       = productWorkingAudit.WorkingID;
                            productWorkings.WorkingName     = productWorkingAudit.WorkingNameNew;
                            productWorkings.SortOrder       = productWorkingAudit.SortOrderNew;
                            productWorkings.Unit            = productWorkingAudit.Unit;
                            productWorkings.ValueType       = productWorkingAudit.ValueTypeNew;
                            productWorkings.ValueTypeName   = TextUtils.ToString(grvData.GetRowCellValue(selectedRowHandle, colValueTypeNews));
                            productWorkings.IsHidden        = TextUtils.ToBoolean(grvData.GetRowCellValue(selectedRowHandle, colIsHiddenNew));
                            productWorkings.MaxValue        = productWorkingAudit.MaxValueNew;
                            productWorkings.MinValue        = productWorkingAudit.MinValueNew;
                            productWorkings.CheckValueType  = productWorkingAudit.CheckValueTypeNew;
                            productWorkings.ProductStepCode = productWorkingAudit.ProductStepCodeNew;
                            productWorkings.PeriodValue     = productWorkingAudit.PeriodValueNew;
                            productWorkings.CreatedBy       = productWorkingAudit.CreatedBy;
                            productWorkings.UpdatedBy       = productWorkingAudit.UpdatedBy;
                            productWorkings.CreatedDate     = productWorkingAudit.CreatedDate;
                            productWorkings.UpdatedDate     = productWorkingAudit.UpdatedDate;
                            productWorkings.IsApproved      = 2;
                            productWorkings.ActionType      = 1;
                            ProductWorkingBO.Instance.Insert(productWorkings);
                        }
                    }
                    else if (productWorkingAudit.ActionType == 2)
                    {
                        productWorking.ProductID       = productWorkingAudit.ProductID;
                        productWorking.ProductStepID   = productWorkingAudit.ProductStepID;
                        productWorking.WorkingID       = productWorkingAudit.WorkingID;
                        productWorking.WorkingName     = productWorkingAudit.WorkingNameNew;
                        productWorking.SortOrder       = productWorkingAudit.SortOrderNew;
                        productWorking.Unit            = productWorkingAudit.Unit;
                        productWorking.IsHidden        = productWorkingAudit.IsHiddenNew;
                        productWorking.ValueType       = productWorkingAudit.ValueTypeNew;
                        productWorking.MaxValue        = productWorkingAudit.MaxValueNew;
                        productWorking.MinValue        = productWorkingAudit.MinValueNew;
                        productWorking.CheckValueType  = productWorkingAudit.CheckValueTypeNew;
                        productWorking.ProductStepCode = productWorkingAudit.ProductStepCodeNew;
                        productWorking.PeriodValue     = productWorkingAudit.PeriodValueNew;
                        productWorking.CreatedBy       = productWorkingAudit.CreatedBy;
                        productWorking.UpdatedBy       = productWorkingAudit.UpdatedBy;
                        productWorking.CreatedDate     = productWorkingAudit.CreatedDate;
                        productWorking.UpdatedDate     = productWorkingAudit.UpdatedDate;
                        productWorking.IsApproved      = 2;
                        productWorking.ActionType      = 2;
                        ProductWorkingBO.Instance.Update(productWorking);
                    }
                    else if (productWorkingAudit.ActionType == 3)
                    {
                        ProductWorkingBO.Instance.Delete(ProductWorkingID);
                    }
                }
            }
            LoadInfoSearch();
        }
Ejemplo n.º 23
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }
                grvData.FocusedRowHandle = -1;

                PaymentTable.IsDeleted   = false;
                PaymentTable.Note        = "";
                PaymentTable.Number      = txtNumber.Text.Trim();
                PaymentTable.TotalTM     = TextUtils.ToDecimal(colTM.SummaryItem.SummaryValue);
                PaymentTable.TotalCK     = TextUtils.ToDecimal(colCK.SummaryItem.SummaryValue);
                PaymentTable.UpdatedBy   = Global.AppUserName;
                PaymentTable.UpdatedDate = DateTime.Now;

                if (PaymentTable.ID == 0)
                {
                    PaymentTable.CreatedBy   = Global.AppUserName;
                    PaymentTable.CreatedDate = DateTime.Now;
                    PaymentTable.ID          = (long)pt.Insert(PaymentTable);
                }
                else
                {
                    pt.Update(PaymentTable);
                }

                for (int i = 0; i < grvData.RowCount; i++)
                {
                    string code = TextUtils.ToString(grvData.GetRowCellValue(i, colCode));
                    if (code == "")
                    {
                        continue;
                    }

                    long id = TextUtils.ToInt64(grvData.GetRowCellValue(i, colID));
                    PaymentTableItemModel item = new PaymentTableItemModel();
                    if (id > 0)
                    {
                        item = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(id);
                    }
                    item.Code         = code;
                    item.Content      = TextUtils.ToString(grvData.GetRowCellValue(i, colContent));
                    item.ContentCheck = TextUtils.ToString(grvData.GetRowCellValue(i, colContentCheck));
                    item.Target       = TextUtils.ToString(grvData.GetRowCellValue(i, colTarget));
                    item.Name         = TextUtils.ToString(grvData.GetRowCellValue(i, colName));
                    item.Note         = TextUtils.ToString(grvData.GetRowCellValue(i, colNote));

                    item.PaymentTableID = PaymentTable.ID;

                    item.IsCash = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsTM));

                    item.Total        = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colTotal));
                    item.TotalTH      = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colTotalTH));
                    item.DeliveryCost = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colDeliveryCost));
                    item.DiffCost     = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colDiffCost));

                    item.PercentPay = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colPercentPay));
                    item.TotalCash  = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colTM));
                    item.TotalCK    = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colCK));

                    item.UserId = TextUtils.ToString(grvData.GetRowCellValue(i, colOrderUserId));

                    item.CompanyID    = TextUtils.ToInt(grvData.GetRowCellValue(i, colCompany));
                    item.DepartmentId = TextUtils.ToString(grvData.GetRowCellValue(i, colDepartment));
                    item.ProjectId    = TextUtils.ToString(grvData.GetRowCellValue(i, colProject));
                    item.CostID       = TextUtils.ToInt(grvData.GetRowCellValue(i, colCost));
                    item.CountProject = TextUtils.ToInt(grvData.GetRowCellValue(i, colCountProject));
                    item.VAT          = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVAT));

                    item.ContractStatus = TextUtils.ToInt1(grvData.GetRowCellValue(i, colContractStatus));
                    item.InvoiceStatus  = TextUtils.ToInt1(grvData.GetRowCellValue(i, colInvoiceStatus));
                    item.IsPO           = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsPO));
                    item.IsCongNo       = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsCongNo));
                    item.IsCuongVe      = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsCuongVe));
                    item.IsGDD          = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsGĐĐ));
                    item.IsTTGH         = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsTTGH));
                    item.IsVV_DA_NCC    = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsVV_DA_NCC));

                    if (id > 0)
                    {
                        pt.Update(item);
                    }
                    else
                    {
                        pt.Insert(item);
                    }

                    ArrayList listOrder = OrdersBO.Instance.FindByAttribute("OrderCode", item.Code);
                    if (listOrder.Count > 0)
                    {
                        OrdersModel order = (OrdersModel)listOrder[0];
                        order.StatusTT = 2;
                        pt.UpdateQLSX(order);
                    }
                }

                pt.CommitTransaction();
                loadItems();
                _isSaved = true;
                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
Ejemplo n.º 24
0
        void save()
        {
            if (Global.AppUserName != ProposalProblem.UpdatedBy && ProposalProblem.ID > 0)
            {
                MessageBox.Show("Bạn không có quyền sửa vấn đề này!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                grvData.FocusedRowHandle    = -1;
                ProposalProblem.ProposalId  = Proposal.ProposalId;
                ProposalProblem.Reason      = txtReason.Text.Trim();
                ProposalProblem.Solution    = txtSolution.Text.Trim();
                ProposalProblem.IsCompleted = 0;
                ProposalProblem.UpdatedDate = DateTime.Now;
                ProposalProblem.UpdatedBy   = Global.AppUserName;

                if (ProposalProblem.ID <= 0)
                {
                    ProposalProblem.CreatedDate = DateTime.Now;
                    ProposalProblem.CreatedBy   = Global.AppUserName;
                    ProposalProblem.ID          = (int)pt.Insert(ProposalProblem);
                }
                else
                {
                    pt.Update(ProposalProblem);
                }

                for (int i = 0; i < grvData.RowCount; i++)
                {
                    ProposalProblemActionModel action = new ProposalProblemActionModel();
                    int id = TextUtils.ToInt(grvData.GetRowCellValue(i, colID));
                    if (id > 0)
                    {
                        action = (ProposalProblemActionModel)ProposalProblemActionBO.Instance.FindByPK(id);
                    }

                    action.Action            = TextUtils.ToString(grvData.GetRowCellValue(i, colAction));
                    action.ProposalProblemID = ProposalProblem.ID;
                    action.UserId            = TextUtils.ToString(grvData.GetRowCellValue(i, colUserId));
                    action.Deadline          = TextUtils.ToDate2(grvData.GetRowCellValue(i, colDeadline));
                    action.IsCompleted       = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsCompleted));

                    if (id > 0)
                    {
                        ProposalProblemActionBO.Instance.Update(action);
                    }
                    else
                    {
                        ProposalProblemActionBO.Instance.Insert(action);
                    }
                }

                pt.CommitTransaction();
                loadGrid();
                _isSaved = true;

                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }

            if (_isSaved)
            {
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 25
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();
        }
Ejemplo n.º 26
0
        bool checkCT(string SelectedGPpath)
        {
            _dtLocal = new DataTable();
            _dtLocal.Columns.Add("Name", typeof(string));
            _dtLocal.Columns.Add("Size", typeof(string));
            _dtLocal.Columns.Add("Type", typeof(string));
            _dtLocal.Columns.Add("Hang", typeof(string));
            _dtLocal.Columns.Add("PathLocal", typeof(string));
            _dtLocal.Columns.Add("Path3D", typeof(string));
            _dtLocal.Columns.Add("NameVT", typeof(string));

            string _code = "";

            _code = Path.GetFileName(SelectedGPpath);
            _code = _code.Substring(3, 8);

            //_dtLocal.Rows.Clear();

            DataTable dtCT = TextUtils.Select("Select * from DesignStructure where Type = 3");//lấy những thư mục cấu trúc cơ khí

            string[] listDirectories = Directory.GetDirectories(SelectedGPpath, "**", SearchOption.AllDirectories);

            foreach (string item in listDirectories)
            {
                string folderName = Path.GetFileName(item);
                int    count      = 0;
                foreach (DataRow r in dtCT.Rows)
                {
                    string formatFolder = r["Name"].ToString().Replace("code", _code);
                    if (folderName != formatFolder)
                    {
                        count = 1;
                    }
                    else
                    {
                        count = 0;
                        break;
                    }
                }
                if (count == 1)
                {
                    DataRow row = _dtLocal.NewRow();
                    row["Name"]      = folderName;
                    row["PathLocal"] = item;
                    row["Type"]      = "Folder THỪA";
                    _dtLocal.Rows.Add(row);
                }
            }

            foreach (DataRow itemRow in dtCT.Rows)
            {
                string nameCT = itemRow["Name"].ToString().Replace("code", _code);//OldVersions
                int    iD     = TextUtils.ToInt(itemRow["ID"]);

                string[] arrExtension = null;

                try
                {
                    arrExtension = itemRow["Extension"].ToString().Split(',').Where(o => o.Trim() != "").ToArray();
                }
                catch (Exception)
                {
                }

                string folderPath = Path.GetDirectoryName(SelectedGPpath) + "\\" + itemRow["Path"].ToString().Replace("code", _code);
                if (!Directory.Exists(folderPath))
                {
                    DataRow row = _dtLocal.NewRow();
                    row["Name"]      = nameCT;
                    row["PathLocal"] = folderPath;
                    row["Type"]      = "THIẾU THƯ MỤC";
                    _dtLocal.Rows.Add(row);
                }
                else
                {
                    DataTable dtCTFile  = TextUtils.Select("SELECT * FROM DesignStructureFile where DesignStructureID = " + iD);
                    string[]  listFiles = Directory.GetFiles(folderPath, "*.*", SearchOption.TopDirectoryOnly);

                    if (dtCTFile.Rows.Count > 0)
                    {
                        foreach (DataRow row in dtCTFile.Rows)
                        {
                            string fileNameCT = row["Name"].ToString().Replace("code", _code);
                            bool   exist      = TextUtils.ToBoolean(row["Exist"]);
                            if (exist)
                            {
                                int count = 0;
                                try
                                {
                                    count = listFiles.Count(o => Path.GetFileName(o).Contains(Path.GetFileNameWithoutExtension(fileNameCT)));
                                }
                                catch
                                {
                                }
                                if (count == 0)
                                {
                                    DataRow row1 = _dtLocal.NewRow();
                                    row1["Name"]      = fileNameCT;
                                    row1["PathLocal"] = folderPath;
                                    row1["Type"]      = "THIẾU FILE";
                                    _dtLocal.Rows.Add(row1);
                                }
                            }
                        }
                    }

                    if (listFiles.Count() > 0)
                    {
                        foreach (string item in listFiles)
                        {
                            string fileName    = Path.GetFileName(item);
                            string textCompare = fileName.Split('-')[0];
                            if (dtCTFile.Rows.Count > 0)
                            {
                                int count = 0;
                                try { count = dtCTFile.Select().Count(r => Path.GetFileNameWithoutExtension(r["Name"].ToString().Replace("code", _code)) == textCompare); }
                                catch { }
                                if (count == 0)
                                {
                                    DataRow row1 = _dtLocal.NewRow();
                                    row1["Name"]      = fileName;
                                    row1["Size"]      = new FileInfo(item).Length;
                                    row1["PathLocal"] = item;
                                    row1["Type"]      = "THỪA";
                                    _dtLocal.Rows.Add(row1);
                                    continue;
                                }
                            }

                            if (arrExtension != null && arrExtension.Count() > 0 && !arrExtension.Contains(Path.GetExtension(fileName)))
                            {
                                DataRow row1 = _dtLocal.NewRow();
                                row1["Name"]      = fileName;
                                row1["Size"]      = new FileInfo(item).Length;
                                row1["PathLocal"] = item;
                                row1["Type"]      = "THỪA";
                                _dtLocal.Rows.Add(row1);
                            }
                        }
                    }
                }
            }

            if (_dtLocal.Rows.Count == 0)
            {
                //MessageBox.Show("Cấu trúc giải pháp chuẩn", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(true);
            }
            else
            {
                //MessageBox.Show("Cấu trúc giải pháp chưa chuẩn", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }