Пример #1
0
        //void loadUser()
        //{
        //    DataTable dt = TextUtils.Select("Select * from vUserInfo WITH(NOLOCK)");

        //    repositoryItemLookUpEdit1.DataSource = dt;
        //    repositoryItemLookUpEdit1.DisplayMember = "UserName";
        //    repositoryItemLookUpEdit1.ValueMember = "UserId";
        //}

        void LoadInfoSearch()
        {
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load dữ liệu..."))
            {
                try
                {
                    if (isViewAll)
                    {
                        _dtData = TextUtils.Select("select * from vTheoDoi with(nolock)" + (chkNotComplete.Checked ? " where Status = 0" : ""));
                    }
                    else
                    {
                        _dtData = TextUtils.Select("select * from vTheoDoi with(nolock) where UserID = " +
                                                   Global.UserID + (chkNotComplete.Checked ? " and Status = 0" : ""));
                    }

                    grdData.DataSource = _dtData;
                    if (_rownIndex >= grvData.RowCount)
                    {
                        _rownIndex = 0;
                    }
                    if (_rownIndex > 0)
                    {
                        grvData.FocusedRowHandle = _rownIndex;
                    }
                    grvData.SelectRow(_rownIndex);
                    grvData.BestFitColumns();
                }
                catch
                {
                }
            }
        }
Пример #2
0
 private bool ValidateForm()
 {
     if (txtName.Text.Trim() == "")
     {
         MessageBox.Show("Xin hãy điền Tên cho quyền này.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
         return(false);
     }
     if (txtCode.Text.Trim() == "")
     {
         MessageBox.Show("Xin hãy điền Mã cho quyền này.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
         return(false);
     }
     else
     {
         DataTable dt;
         if (Model.ID > 0)
         {
             dt = TextUtils.Select("select Code from FormAndFunction where Code = '" + txtCode.Text.Trim() + "' and ID <> " + Model.ID);
         }
         else
         {
             dt = TextUtils.Select("select Code from FormAndFunction where Code = '" + txtCode.Text.Trim() + "'");
         }
         if (dt != null)
         {
             if (dt.Rows.Count > 0)
             {
                 MessageBox.Show("Mã này đã tồn tại!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #3
0
        void loadDegree()
        {
            DataTable dt = TextUtils.Select("Select * from Degrees WITH(NOLOCK) WHERE UserID = " + Model.ID);

            grdData.DataSource = dt;
            grvData.BestFitColumns();
        }
Пример #4
0
 private bool checkValid()
 {
     if (txtKey.Text == "")
     {
         MessageBox.Show("Xin hãy điền tên.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
         return(false);
     }
     else
     {
         DataTable dt;
         if (_model.ID > 0)
         {
             dt = TextUtils.Select("select KeyName from ConfigSystem where KeyName = '" + txtKey.Text.Trim() + "' and ID <> " + _model.ID);
         }
         else
         {
             dt = TextUtils.Select("select KeyName from ConfigSystem where KeyName = '" + txtKey.Text.Trim() + "'");
         }
         if (dt != null)
         {
             if (dt.Rows.Count > 0)
             {
                 MessageBox.Show("Mã này đã tồn tại!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #5
0
        void loadGrid()
        {
            DataTable dt = TextUtils.Select("vModuleError", null);

            grdData.DataSource = dt;
            grvData.BestFitColumns();
        }
Пример #6
0
 void loadFile()
 {
     _dtFile = TextUtils.Select("select * from SolutionFile with(nolock) where SolutionID = " + Solution.ID
                                + " and SolutionFileTypeID = " + TextUtils.ToInt(grvGroupFile.GetFocusedRowCellValue(colGFID)));
     _dtFile.Columns.Add("LocalPath");
     grdFile.DataSource = _dtFile;
 }
Пример #7
0
        public void LoadData()
        {
            DataTable dt = new DataTable();

            dt = TextUtils.Select("select ProjectName,ProjectCode,ProjectId from ProjectSyn");
            leDuAn.Properties.DataSource    = dt;
            leDuAn.Properties.ValueMember   = "ProjectCode";
            leDuAn.Properties.DisplayMember = "ProjectName";


            dt = TextUtils.Select("SELECT Name, Code, ID FROM UserGroup");
            leNhom.Properties.DataSource    = dt;
            leNhom.Properties.DisplayMember = "Name";
            leNhom.Properties.ValueMember   = "ID";

            DataTable dt2 = TextUtils.Select("SELECT DISTINCT ProjectSyn.ProjectName + '- ' + ProjectSyn.ProjectCode + N'- hạn hoàn thành '+ CONVERT(VARCHAR(10),ProjectSyn.DateFinishE,103) AS ProjectName, ProjectSyn.DateFinishE, ProjectSyn.ProjectCode,ProjectSyn.DateFinishE, SanPhamDA.TenTheoHopDong + '- ' + SanPhamDA.MaTheoHopDong AS TenTheoHopDong, SanPhamDA.MaTheoHopDong, UserGroup.Name, HangMucCongViec.ID, HangMucCongViec.TenHangMuc, HangMucCongViec.ThoiGianTK,CONVERT(VARCHAR(10),HangMucCongViec.ThoiGianBDDuKien,103) as ThoiGianBDDuKien, CONVERT(VARCHAR(10),HangMucCongViec.ThoiGianKTDuKien,103) as ThoiGianKTDuKien, HangMucCongViec.NguoiThietKe, HangMucCongViec.MucDoUuTien, HangMucCongViec.TinhTrang, HangMucCongViec.KieuCongViec, HangMucCongViec.Loi, HangMucCongViec.SanPhamDAID FROM SanPhamDA INNER JOIN UserGroup ON SanPhamDA.NhomPhuTrach = UserGroup.ID INNER JOIN ProjectSyn ON SanPhamDA.ProjectsID COLLATE Vietnamese_CI_AS = ProjectSyn.ProjectId LEFT OUTER JOIN HangMucCongViec ON SanPhamDA.ID = HangMucCongViec.SanPhamDAID");

            grdData.DataSource = dt2;
            //DataTable dtf = TextUtils.Select("SELECT DISTINCT ProjectSyn.ProjectName + '- ' + ProjectSyn.ProjectCode AS ProjectName, ProjectSyn.ProjectCode, ProjectSyn.DateFinishE,datediff(d,getdate(),ProjectSyn.DateFinishE) as NgayConLai FROM SanPhamDA INNER JOIN ProjectSyn ON SanPhamDA.ProjectsID COLLATE Vietnamese_CI_AS = ProjectSyn.ProjectId order by ProjectName asc");
            //grdTinhTrangDA.DataSource = dtf;
            repositoryItemLookUpEdit1.DataSource    = TextUtils.Select("SELECT Code,ID, FullName FROM Users");
            repositoryItemLookUpEdit1.DisplayMember = "FullName";
            repositoryItemLookUpEdit1.ValueMember   = "ID";

            grvData.BestFitColumns();
        }
Пример #8
0
 public void ProcessLoadData()
 {
     try
     {
         //Load trạng thái khi bắt đầu search.
         SetMode(true);
         //Truy xuất dữ liệu.
         DataTable Source = TextUtils.Select("Select * from File3D WITH(NOLOCK) where ProductGroupID = " + _catID + " ORDER BY Name");
         //Đổ dữ liệu lên grid
         this.BeginInvoke((MethodInvoker) delegate
         {
             grdData.DataSource = Source;
             //Focus con trỏ chuột tại dòng đã select khi load lại dữ liệu
             if (_RownIndex >= grvData.RowCount)
             {
                 _RownIndex = 0;
             }
             if (_RownIndex > 0)
             {
                 grvData.FocusedRowHandle = _RownIndex;
             }
             grvData.BestFitColumns();
         });
         //Kết thúc khi load xong dữ liệu
         SetMode(false);
         //Focus
         this.BeginInvoke((MethodInvoker) delegate { this.SetFocus(); });
     }
     catch (Exception ex)
     {
         SetMode(false);
         thSearch.Abort();
         return;
     }
 }
Пример #9
0
        void loadTree()
        {
            try
            {
                DataTable tbl = TextUtils.Select("Select ID,Name,ParentID from ProductGroup with(nolock) WHERE (Type = 0 or Type = 1) order by Name");

                DataRow row = tbl.NewRow();
                row["ID"]   = 0;
                row["Name"] = "Thư viện 3D Điện Tử, Nguyên Lý";
                tbl.Rows.InsertAt(row, 1);

                treeData.DataSource       = tbl;
                treeData.KeyFieldName     = "ID";
                treeData.PreviewFieldName = "Name";

                treeData.ExpandAll();

                DevExpress.XtraTreeList.Nodes.TreeListNode currentNode = treeData.FindNodeByFieldValue("ID", _curentNode);
                treeData.SetFocusedNode(currentNode);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
            }
        }
Пример #10
0
        void LoadUnavailableData()
        {
            string    sql = "SELECT KnifeDetailList.*, Users.UserCode, Users.DepartmentCode FROM dbo.KnifeDetailList, dbo.Users WHERE dbo.KnifeDetailList.WorkerID = dbo.Users.ID AND KnifeDetailList.Status = 0";
            DataTable arr = TextUtils.Select(sql);

            dtgvKnife.DataSource = arr;
        }
Пример #11
0
        private void frmBaoGiaNew_Load(object sender, EventArgs e)
        {
            cboCustomerPercentType.SelectedIndex = 1;
            cboPriceType.SelectedIndex           = 0;

            loadProject();
            loadCustomer();
            loadCostGroup();
            loadModule();
            loadDiffCost();

            if (BaoGia.ID > 0)
            {
                txtBaoGiaCode.Text         = BaoGia.Code;
                txtCustomerCash.Text       = BaoGia.CustomerCash.ToString();
                txtCustomerCode.Text       = BaoGia.CustomerCode;
                txtCustomerName.Text       = BaoGia.CustomerName;
                txtCustomerPercent.Text    = BaoGia.CustomerPercent.ToString();
                txtCustomerTotal.Text      = BaoGia.CustomerTotal.ToString();
                txtFinishCustomerCode.Text = BaoGia.CustomerCodeF;
                txtFinishCustomerName.Text = BaoGia.CustomerNameF;
                txtProjectCode.Text        = BaoGia.ProjectCode;
                txtProjectName.Text        = BaoGia.ProjectName;

                cboCustomerPercentType.SelectedIndex = BaoGia.CustomerPercentType;
            }
            _dtProduct = TextUtils.Select("select distinct productcode, productname FROM [QLKHCV].[dbo].[BaoGiaItem] with(nolock) where BaoGiaID = " + BaoGia.ID);
            loadProduct();
            loadBaogiaItem();
        }
Пример #12
0
        void loadGrid()
        {
            DataTable dt = TextUtils.Select("Select a.* from vWorks a WITH(NOLOCK) Order by Priority");

            grdData.DataSource = null;
            grdData.DataSource = dt;
        }
Пример #13
0
        void loadGrid()
        {
            DataTable dt = TextUtils.Select("Select *,0 as Price,0 as TotalPrice,0 as PriceType from vBaiThucHanhModule with(nolock) where BaiThucHanhID = " + BaiThucHanh.ID);

            foreach (DataRow row in dt.Rows)
            {
                string code = row["Code"].ToString();
                try
                {
                    if (code.StartsWith("TPAD."))
                    {
                        DataTable dtPrice = TextUtils.LoadModulePriceTPAD(code, false);
                        row["Price"]      = TextUtils.ToInt(dtPrice.Compute("Sum(TotalPrice)", ""));
                        row["TotalPrice"] = TextUtils.ToInt(row["Qty"]) * TextUtils.ToInt(row["Price"]);
                        row["PriceType"]  = TextUtils.ToInt(dtPrice.Rows[0]["PriceType"]);
                    }
                    else
                    {
                        string    sql     = "select top 1 Price from [Parts] with(nolock) where Replace(PartsCode,' ','') = '" + code.Replace(" ", "") + "'";
                        DataTable dtPrice = LibQLSX.Select(sql);
                        row["Price"]      = TextUtils.ToInt(dtPrice.Rows[0][0]);
                        row["TotalPrice"] = TextUtils.ToInt(row["Qty"]) * TextUtils.ToInt(row["Price"]);
                        row["PriceType"]  = 1;
                    }
                }
                catch (Exception)
                {
                }
            }
            grdModule.DataSource = dt;
        }
Пример #14
0
        public void SelectAll(ref DataTable dt, GridControl grd)
        {
            try
            {
                LeNhanVien.DataSource    = TextUtils.Select("SELECT Code,ID, FullName FROM Users WHERE (UserGroupID =" + grvDataSP.GetFocusedRowCellValue(colNhomPhuTrach) + ")");
                LeNhanVien.DisplayMember = "FullName";
                LeNhanVien.ValueMember   = "ID";
                if (grvData.RowCount < 0)
                {
                    return;
                }
                dt = TextUtils.Select("SELECT * FROM HangMucCongViec WHERE (SanPhamDAID = " + grvDataSP.GetFocusedRowCellValue(colID) + ")");
                if (dt == null)
                {
                    dt = HangMucCongViecBO.KhoiTaoGrid();
                }
                grdData.DataSource = dt;

                grvData.BestFitColumns();
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #15
0
        private void frmFile3DGroupcs_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = TextUtils.Select("ConfigSystem", new Expression("KeyName", "3D"));
                DPath = dt.Rows[0][2].ToString();
                Directory.CreateDirectory(DPath);

                loadCombo(ParentID);
                cboParent.SelectedValue = ParentID;
                cboParent.Enabled       = false;

                if (Model.ID != 0)
                {
                    txtName.Text = Model.Name;
                    _currentPath = Model.Path;
                }
                else
                {
                    if (ParentID != 0)
                    {
                        DPath = ((ProductGroupModel)ProductGroupBO.Instance.FindByPK(ParentID)).Path;
                    }
                }
            }
            catch (Exception ex)
            {
                TextUtils.ShowError(ex);
            }
        }
Пример #16
0
        /// <summary>
        /// ShowDataInGrid
        /// </summary>
        private void AddNewRowInDataTable()
        {
            DataTable dt1 = TextUtils.Select(string.Format("SELECT * FROM dbo.Testta WHERE OrderCode = '{0}' order by number", txtOrderNo.Text.Trim()));

            if (dt1.Rows.Count == 0)
            {
                dateTimePicker1.CustomFormat = "dd/MM/yyyy";
                dateTimePicker1.Value        = DateTime.Now;
                //dateTimePicker1.Value = new DateTime(2012,1,1);
                dt1 = TextUtils.Select("SELECT * FROM dbo.Testta WHERE ID = 0");
                for (int i = 0; i < Qty; i++)
                {
                    DataRow r = dt1.NewRow();
                    r["Number"] = i + 1;
                    dt1.Rows.Add(r);
                }

                grdData.DataSource = dt1;
            }
            else
            {
                grdData.DataSource           = dt1;
                dateTimePicker1.CustomFormat = "dd/MM/yyyy";
                dateTimePicker1.Value        = Convert.ToDateTime(dt1.Rows[0]["DateWork"]);
                txtWorkerName.Text           = TextUtils.ToString(dt1.Rows[0]["WorkerName"]);
                txtName.Text   = TextUtils.ToString(dt1.Rows[0]["Name"]);
                txtLeader.Text = TextUtils.ToString(dt1.Rows[0]["Leader"]);
            }
        }
Пример #17
0
 private bool ValidateForm()
 {
     if (txtName.Text.Trim() == "")
     {
         MessageBox.Show("Xin hãy điền Tên nhóm.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
         return(false);
     }
     else
     {
         DataTable dt;
         if (Model.ID > 0)
         {
             dt = TextUtils.Select("select Name from ProductGroup where Name = '" + txtName.Text.Trim() + "' and ID <> " + Model.ID + " and ParentID = " + Model.ParentID);
         }
         else
         {
             dt = TextUtils.Select("select Name from ProductGroup where Name = '" + txtName.Text.Trim() + "' and ParentID = " + ParentID);
         }
         if (dt != null)
         {
             if (dt.Rows.Count > 0)
             {
                 MessageBox.Show("Nhóm này đã tồn tại!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 return(false);
             }
         }
     }
     //if (txtPath.Text.Trim()=="")
     //{
     //    MessageBox.Show("Xin hãy điền Đường dẫn.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
     //    return false;
     //}
     return(true);
 }
Пример #18
0
        private void LoadInfoSearch()
        {
            string    sql = @"select *, -1 as Status from GearInfo";
            DataTable dt  = TextUtils.Select(sql);

            grdData.DataSource = dt;
        }
Пример #19
0
        private void frmSolution_Load(object sender, EventArgs e)
        {
            loadTech();
            loadArea();
            loadGroupFile();
            loadFile();
            loadDMVT();
            loadYC();
            loadNguoiPhuTrach();

            if (Solution.ID > 0)
            {
                txtCode.Text            = Solution.Code;
                txtDescription.Text     = Solution.Description;
                txtName.Text            = Solution.Name;
                txtReasonStop.Text      = Solution.StopReason;
                txtTotalCost.EditValue  = Solution.TotalCost;
                txtVersion.Text         = Solution.Version.ToString();
                txtWorkDescription.Text = Solution.WorkDescription;

                cboArea.EditValue          = Solution.Area;
                cboNguoiPhuTrach.EditValue = Solution.NguoiPhuTrach;
                cboRequire.EditValue       = Solution.RequireSolutionID;
                cboStatus.SelectedIndex    = Solution.Status;
                cboTechnology.EditValue    = Solution.SolutionTechnologyID;

                this.Text = "Giải pháp: " + Solution.Code + " - " + Solution.Name;
            }
            else
            {
                cboStatus.SelectedIndex = 0;
                cboRequire.EditValue    = RequireID;
                txtVersion.Text         = "1";

                DataTable dt = TextUtils.Select(" SELECT top 1 Code FROM Solution where Code like 'GP." + CustomerCode + "%' order by ID desc");
                //string code = "GP.000001";
                string code = "GP." + CustomerCode + ".001";
                if (dt.Rows.Count > 0)
                {
                    code = TextUtils.ToString(dt.Rows[0]["Code"]);
                    string number = code.Split('.')[2];
                    code = "GP." + CustomerCode + "." + string.Format("{0:000}", TextUtils.ToInt(number) + 1);
                }
                txtCode.Text = code;
            }

            _dtFolder.Columns.Add("PathName");
            _dtFolder.Columns.Add("FolderNumber");
            _dtFolder.Columns.Add("ParentID", typeof(int));
            _dtFolder.Columns.Add("FileNumber");
            _dtFolder.Columns.Add("ID", typeof(int));
            _dtFolder.Columns.Add("FullPathName");

            _dtFileFTP.Columns.Add("check", typeof(bool));
            _dtFileFTP.Columns.Add("FileName");
            _dtFileFTP.Columns.Add("Size");
            _dtFileFTP.Columns.Add("CreatedDate");
            _dtFileFTP.Columns.Add("FullPath");
            _dtFileFTP.Columns.Add("Name");
        }
Пример #20
0
        private void xemDanhMụcVậtTưCủaCụmToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string code       = TextUtils.ToString(grvData.GetFocusedRowCellValue(colCode));
            string name       = TextUtils.ToString(grvData.GetFocusedRowCellValue(colName));
            string moduleCode = code.Substring(0, 10);

            DataTable dtDMVT = TextUtils.Select("select * from MaterialModuleLink with(nolock) where ModuleCode = '" + moduleCode + "'");

            DataRow[] drs = dtDMVT.Select("Code = '" + code + "'");
            if (drs.Length < 0)
            {
                return;
            }

            string stt = TextUtils.ToString(drs[0]["STT"]);

            DataRow[] drs1 = dtDMVT.Select("STT like '" + stt + ".%'");
            if (drs1.Length > 0)
            {
                DataTable dt = drs1.CopyToDataTable();
                dt.ImportRow(drs[0]);

                frmViewDMVT frm = new frmViewDMVT();
                frm.DtDMVT = dt;
                frm.Code   = code;
                frm.Name   = name;
                frm.Show();
            }
        }
Пример #21
0
        void LoadInfoSearch()
        {
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load dữ liệu..."))
            {
                try
                {
                    _dtData = TextUtils.Select("select * from vUpdateSoftware with(nolock)");

                    grdData.DataSource = _dtData;
                    if (_rownIndex >= grvData.RowCount)
                    {
                        _rownIndex = 0;
                    }
                    if (_rownIndex > 0)
                    {
                        grvData.FocusedRowHandle = _rownIndex;
                    }
                    grvData.SelectRow(_rownIndex);
                    grvData.BestFitColumns();
                }
                catch
                {
                }
            }
        }
Пример #22
0
        public void View_popup()
        {
            string ngaythucte = "", Tb = "";

            for (int i = 0; i < grvData.RowCount; i++)
            {
                if (grvData.GetRowCellValue(i, colTinhTrang).ToString() == "0")
                {
                    DataTable dt = TextUtils.Select("select * from vCheckPermission where Code ='frmTheoDoiCongViec_ViewAll' and UserID=" + Global.UserID);
                    if (dt.Rows.Count > 0 || grvData.GetRowCellValue(i, colNguoiPhuTrach).ToString() == Global.UserID.ToString())
                    {
                        string ma    = grvData.GetRowCellValue(i, colMaDA).ToString();
                        string ten   = grvData.GetRowCellValue(i, colTenCV).ToString();
                        string tenNV = grvData.GetRowCellDisplayText(i, colNguoiPhuTrach).ToString();

                        if (DateTime.Now >= Convert.ToDateTime(grvData.GetRowCellValue(i, colThoiGianKT)))
                        {
                            ngaythucte += "Công việc :" + ten + " - " + ma + " do " + tenNV + " chưa hoàn thành\n";
                            continue;
                        }
                    }
                }
            }
            if (ngaythucte.Trim() != "")
            {
                Tb += ngaythucte;
            }
            if (Tb.Trim() != "")
            {
                PopUp_No(Tb);
            }
        }
Пример #23
0
        void loadGridImage()
        {
            DataTable dt = TextUtils.Select("MisMatchImage", new Expression("MisMatchID", MisMatch.ID));

            grvDataImage.AutoGenerateColumns = false;
            grvDataImage.DataSource          = dt;
        }
Пример #24
0
        private void cboType_SelectionChangeCommitted(object sender, EventArgs e)
        {
            if (cboType.SelectedIndex == -1)
            {
                return;
            }
            int type = cboType.SelectedIndex;

            try
            {
                DataTable dtSum = TextUtils.Select("Select count(*) from vModuleError where Type" + type + " = " + type);
                txtTypeSum.Text = dtSum.Rows[0][0].ToString();

                DataTable dtKP = TextUtils.Select("Select count(*) from vModuleError where Status = 1 and Type" + type + "= " + type);
                txtTypeKP.Text = dtKP.Rows[0][0].ToString();

                txtTypeChua.Text = (TextUtils.ToInt(txtTypeSum.Text) - TextUtils.ToInt(txtTypeKP.Text)).ToString();
            }
            catch (Exception)
            {
            }


            try
            {
                DataTable dt = TextUtils.Select("Select * from vModuleError where Type" + type + " = " + type);
                grdDataType.DataSource = dt;
            }
            catch (Exception)
            {
            }
        }
Пример #25
0
        private bool checkValid(PayVouchersModel dModel)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("Xin hãy điền tên.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }
            else
            {
                DataTable dt;
                if (dModel.ID > 0)
                {
                    dt = TextUtils.Select("select Name from PayVouchers with(nolock) where upper(Replace(Name,' ','')) = '"
                                          + txtName.Text.Trim().ToUpper() + "' and ID <> " + dModel.ID);
                }
                else
                {
                    dt = TextUtils.Select("select Name from PayVouchers with(nolock) where upper(Replace(Name,' ','')) = '"
                                          + txtName.Text.Trim().ToUpper() + "'");
                }
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        MessageBox.Show("Tên này đã tồn tại!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return(false);
                    }
                }
            }

            return(true);
        }
Пример #26
0
        void loadTree()
        {
            try
            {
                DataTable tbl = new DataTable();
                if (txtGroupName.Text.Trim() == "")
                {
                    tbl = TextUtils.Select("Select * from MaterialGroup with(nolock) order by Code");
                }
                else
                {
                    tbl = TextUtils.Select("Select * from MaterialGroup with(nolock) where Name like N'%" + txtGroupName.Text.Trim() + "%' order by Code");
                }

                //DataRow row = tbl.NewRow();
                //row["ID"] = 0;
                //row["Code"] = "All";
                //tbl.Rows.InsertAt(row, 0);

                treeData.DataSource       = tbl;
                treeData.KeyFieldName     = "ID";
                treeData.PreviewFieldName = "Name";
                //treeData.ExpandAll();

                DevExpress.XtraTreeList.Nodes.TreeListNode currentNode = treeData.FindNodeByFieldValue("ID", _curentNode);
                treeData.SetFocusedNode(currentNode);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
            }
        }
        void LoadData()
        {
            string    sql = "SELECT kdl.*, u.UserCode, u.DepartmentCode FROM dbo.KnifeDisposedDetails AS kdl, dbo.Users AS u WHERE kdl.WorkerID = u.ID";
            DataTable arr = TextUtils.Select(sql);

            dtgvKnifeDispose.DataSource = arr;
        }
Пример #28
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (grvData.DataSource == null)
                {
                    return;
                }
                int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                if (id == 0)
                {
                    return;
                }

                if (MaterialFileLinkBO.Instance.CheckExist("MaterialID", id))
                {
                    if (MessageBox.Show("Vật tư [" + grvData.GetFocusedRowCellValue(colName).ToString() + "] đang liên kết với các file thư viện.\n Bạn có thật sự muốn xóa nó không?",
                                        TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.No)
                    {
                        return;
                    }
                    DataTable dt = TextUtils.Select("select Path,MaterialID,MaterialCode from vMaterialFile with(nolock) where FileType = 0 and MaterialID = " + id);
                    if (dt.Rows.Count > 0)
                    {
                        DocUtils.InitFTPTK();
                        DocUtils.DeleteFile(dt.Rows[0][0].ToString());
                    }
                    pt.Delete("Material", id);
                    pt.DeleteByAttribute("MaterialConnect", "MaterialID", id.ToString());
                    pt.DeleteByAttribute("MaterialParameterLink", "MaterialID", id.ToString());
                    pt.DeleteByAttribute("MaterialFileLink", "MaterialID", id.ToString());
                }
                else
                {
                    if (MessageBox.Show("Bạn có chắc muốn xóa vật tư [" + grvData.GetFocusedRowCellValue(colName).ToString() + "] không?",
                                        TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    pt.Delete("Material", id);
                    pt.DeleteByAttribute("MaterialConnect", "MaterialID", id.ToString());
                    pt.DeleteByAttribute("MaterialParameterLink", "MaterialID", id.ToString());
                }

                pt.CommitTransaction();
                LoadInfoSearch();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
Пример #29
0
        private void btnAddGroup_Click(object sender, EventArgs e)
        {
            if (Model.ID == 0)
            {
                MessageBox.Show("Nhân viên này chưa được tạo nên không thể gán nhóm quyền", TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            int userID = Model.ID;
            int count  = 0;

            foreach (int i in gridView1.GetSelectedRows())
            {
                int       userGroupID = TextUtils.ToInt(gridView1.GetRowCellValue(i, colIDGroup));
                DataTable dtLink      = TextUtils.Select("select * from UserGroupLink with(nolock) where UserID = " + userID
                                                         + " and UserGroupID = " + userGroupID);
                if (dtLink.Rows.Count > 0)
                {
                    continue;
                }
                UserGroupLinkModel gLink = new UserGroupLinkModel();
                gLink.UserID      = userID;
                gLink.UserGroupID = userGroupID;
                UserGroupLinkBO.Instance.Insert(gLink);
                count++;
            }
            if (count > 0)
            {
                loadStaffGroupLink();
            }
        }
Пример #30
0
 void LoadInfoSearch()
 {
     using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load danh sách báo giá..."))
     {
         try
         {
             DataTable Source = TextUtils.Select("select *,case when CustomerPercentType = 0 then N'TRƯỚC VAT' ELSE N'SAU VAT' END CustomerPercentTypeText  from BaoGia with(nolock)");
             grdData.DataSource = Source;
             if (_rownIndex >= grvData.RowCount)
             {
                 _rownIndex = 0;
             }
             if (_rownIndex > 0)
             {
                 grvData.FocusedRowHandle = _rownIndex;
             }
             grvData.SelectRow(_rownIndex);
             grvData.BestFitColumns();
         }
         catch (Exception ex)
         {
             return;
         }
     }
 }