Beispiel #1
0
        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            string sErr  = "";
            bool   bVali = true;

            // kiem tra cell cua mot dong dang Edit xem co rong ko?
            if (gridView1.GetRowCellValue(e.RowHandle, "masp").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "slnhap").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "ngaynhap").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "manv").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "ncc").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "barcode").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "sn").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "ghichu").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "model").ToString() == "")

            {
                // chuỗi thông báo lỗi
                bVali = false;
                sErr  = sErr + "Vui lòng điền đầy đủ thông tin!! Nhấn OK để load lại form nhập!!";
            }
            if (bVali)
            {
                //lưu giá trị hiển thị trên gridview vào các biến tương ứng

                string   model    = gridView1.GetRowCellValue(e.RowHandle, "model").ToString();
                string   tensp    = gridView1.GetRowCellValue(e.RowHandle, "tensp").ToString();
                string   masp     = gridView1.GetRowCellValue(e.RowHandle, "masp").ToString();
                string   slnhap   = gridView1.GetRowCellValue(e.RowHandle, "slnhap").ToString();
                string   dvt      = gridView1.GetRowCellValue(e.RowHandle, "dvt").ToString();
                string   ngaynhap = gridView1.GetRowCellValue(e.RowHandle, "ngaynhap").ToString();
                string   manv     = gridView1.GetRowCellValue(e.RowHandle, "manv").ToString();
                string   ncc      = gridView1.GetRowCellValue(e.RowHandle, "ncc").ToString();
                string   sn       = gridView1.GetRowCellValue(e.RowHandle, "sn").ToString();
                string   barcode  = gridView1.GetRowCellValue(e.RowHandle, "barcode").ToString();
                string   ghichu   = gridView1.GetRowCellValue(e.RowHandle, "ghichu").ToString();
                string   sohd     = gridView1.GetRowCellValue(e.RowHandle, "sohd").ToString();
                GridView view     = sender as GridView;
                //kiểm tra xem dòng đang chọn có phải dòng mới không nếu đúng thì insert không thì update
                if (view.IsNewItemRow(e.RowHandle))
                {
                    string insertvt = "insert into VatTu values('" + model + "','" + tensp + "','" + dvt + "')";
                    Connect.Query(insertvt);
                    try
                    {
                        string insert = "insert into Nhap values('" + masp + "','" + slnhap + "','" + Convert.ToDateTime(ngaynhap).ToString("MM/dd/yyyy") + "','" + sn + "','" + barcode + "','" + ncc + "','" + ghichu + "','" + manv + "','" + model + "')";
                        Connect.Query(insert);
                        hien();
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thể kết nối tới CSDL!!");
                    }
                }
                else
                {
                    try
                    {
                        string update = "update Nhap set masp = '" + masp + "', slnhap = '" + slnhap + "',ngaynhap = '" + Convert.ToDateTime(ngaynhap).ToString("MM/dd/yyyy") + "', manv = '" + manv + "', ncc ='" + ncc + "' ,ghichu='" + ghichu + "',barcode='" + barcode + "',sn='" + sn + "', model = '" + model + "'where sohd = '" + sohd + "'";
                        Connect.Query(update);
                        hien();
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thể kết nối tới CSDL!!");
                    }
                }
            }
            else
            {
                DialogResult tb = XtraMessageBox.Show(sErr, "Lỗi trong quá trình nhập!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (tb == DialogResult.OK)
                {
                    // load lại form
                    hien();
                }
            }
        }
Beispiel #2
0
        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            string sErr  = "";
            bool   bVali = true;

            // kiem tra cell cua mot dong dang Edit xem co rong ko?
            if (gridView1.GetRowCellValue(e.RowHandle, "manv").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "tennv").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "username").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "password").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "quyen").ToString() == "")
            {
                // chuỗi thông báo lỗi
                bVali = false;
                sErr  = sErr + "Vui lòng điền đầy đủ thông tin!! Nhấn OK để load lại form nhập!!";
            }
            if (bVali)
            {
                //lưu giá trị hiển thị trên gridview vào các biến tương ứng

                string manv     = gridView1.GetRowCellValue(e.RowHandle, "manv").ToString();
                string tennv    = gridView1.GetRowCellValue(e.RowHandle, "tennv").ToString();
                string username = gridView1.GetRowCellValue(e.RowHandle, "username").ToString();
                string pass     = gridView1.GetRowCellValue(e.RowHandle, "password").ToString();
                string quyen    = gridView1.GetRowCellValue(e.RowHandle, "quyen").ToString();



                GridView view = sender as GridView;
                //kiểm tra xem dòng đang chọn có phải dòng mới không nếu đúng thì insert không thì update
                if (view.IsNewItemRow(e.RowHandle))
                {
                    try
                    {
                        string insert = "insert into NhanVien values('" + manv + "','" + tennv + "','" + username + "','" + pass + "','" + quyen + "' )";
                        Connect.Query(insert);
                        hien();
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thể kết nối tới CSDL!!");
                    }
                }
                else
                {
                    try
                    {
                        string update = "update NhanVien set manv = '" + manv + "', tennv = '" + tennv + "',username = '******',password = '******',quyen = '" + quyen + "' ";
                        Connect.Query(update);
                        hien();
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thể kết nối tới CSDL!!");
                    }
                }
            }
            else
            {
                DialogResult tb = XtraMessageBox.Show(sErr, "Lỗi trong quá trình nhập!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (tb == DialogResult.OK)
                {
                    // load lại form
                    hien();
                }
            }
        }
Beispiel #3
0
        private void LoadData()
        {
            string sql = "select YeuCau.tenmay, stt, thietbinc, chitietnc, ngaync, lydo, trangthai, YeuCau.ghichu, nguoinc, PC.chumay, PC.maphong from YeuCau inner join PC on PC.tenmay = YeuCau.tenmay order by ngaync desc";

            gridControl1.DataSource = Connect.getTable(sql);
        }
Beispiel #4
0
        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            string sErr  = "";
            bool   bVali = true;

            // kiem tra cell cua mot dong dang Edit xem co rong ko?
            if (gridView1.GetRowCellValue(e.RowHandle, "tenmay").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "thietbinc").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "chitietnc").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "ngaync").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "lydo").ToString() == "" ||
                gridView1.GetRowCellValue(e.RowHandle, "trangthai").ToString() == "")

            {
                bVali = false;
                sErr  = sErr + "Vui lòng điền đầy đủ thông tin!! Nhấn OK để load lại form !!";
            }

            if (bVali)
            {
                //lưu giá trị hiển thị trên gridview vào các biến tương ứng
                string tenmay    = gridView1.GetRowCellValue(e.RowHandle, "tenmay").ToString();
                string thietbinc = gridView1.GetRowCellValue(e.RowHandle, "thietbinc").ToString();
                string chitietnc = gridView1.GetRowCellValue(e.RowHandle, "chitietnc").ToString();
                string ngaync    = gridView1.GetRowCellValue(e.RowHandle, "ngaync").ToString();
                string lydo      = gridView1.GetRowCellValue(e.RowHandle, "lydo").ToString();
                string trangthai = gridView1.GetRowCellValue(e.RowHandle, "trangthai").ToString();
                string nguoinc   = gridView1.GetRowCellValue(e.RowHandle, "nguoinc").ToString();
                string ghichu    = gridView1.GetRowCellValue(e.RowHandle, "ghichu").ToString();
                string stt       = gridView1.GetRowCellValue(e.RowHandle, "stt").ToString();

                GridView view = sender as GridView;
                //kiểm tra xem dòng đang chọn có phải dòng mới không nếu đúng thì insert không thì update
                if (view.IsNewItemRow(e.RowHandle))
                {
                    try
                    {
                        string insert = "insert into YeuCau values('" + tenmay + "',N'" + thietbinc + "',N'" + chitietnc + "','" + Convert.ToDateTime(ngaync).ToString("MM/dd/yyyy") + "',N'" + lydo + "',N'" + trangthai + "',N'" + ghichu + "',N'" + nguoinc + "')";
                        Connect.Query(insert);
                        LoadData();
                        if (trangthai == "Đã nâng cấp")
                        {
                            XtraMessageBox.Show("Add danh sách thành công! Hãy update lại cấu hình máy bạn vừa ADD");
                        }
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thế kết nối tới CSDL!!");
                    }
                }
                else
                {
                    try
                    {
                        string update = "update YeuCau set tenmay = '" + tenmay + "', thietbinc = '" + thietbinc + "', chitietnc = N'" + chitietnc + "',ngaync = '" + Convert.ToDateTime(ngaync).ToString("MM/dd/yyyy") + "', lydo = N'" + lydo + "', trangthai =N'" + trangthai + "' ,ghichu=N'" + ghichu + "', nguoinc = N'" + nguoinc + "'where stt = '" + stt + "' ";
                        Connect.Query(update);
                        LoadData();
                        if (trangthai == "Đã nâng cấp")
                        {
                            XtraMessageBox.Show("Cập nhật thành công! Hãy update lại cấu hình máy bạn vừa ADD");
                        }
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thế kết nối tới CSDL!!");
                    }
                }
            }
            else
            {
                DialogResult tb = XtraMessageBox.Show(sErr, "Lỗi trong quá trình Xuất!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (tb == DialogResult.OK)
                {
                    LoadData();
                }
            }
        }
Beispiel #5
0
        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            string sErr  = "";
            bool   bVali = true;

            // kiem tra cell cua mot dong dang Edit xem co rong ko?
            if (gridView1.GetRowCellValue(e.RowHandle, "tenmay").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "ram").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "chip").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "hdd").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "manhinh").ToString() == "" ||
                gridView1.GetRowCellValue(e.RowHandle, "tenuser").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "chumay").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "maphong").ToString() == "")

            {
                bVali = false;
                sErr  = sErr + "Vui lòng điền đầy đủ thông tin!! Nhấn OK để load lại form !!";
            }

            if (bVali)
            {
                //lưu giá trị hiển thị trên gridview vào các biến tương ứng
                string tenmay  = gridView1.GetRowCellValue(e.RowHandle, "tenmay").ToString();
                string ram     = gridView1.GetRowCellValue(e.RowHandle, "ram").ToString();
                string chip    = gridView1.GetRowCellValue(e.RowHandle, "chip").ToString();
                string hdd     = gridView1.GetRowCellValue(e.RowHandle, "hdd").ToString();
                string ssd     = gridView1.GetRowCellValue(e.RowHandle, "ssd").ToString();
                string manhinh = gridView1.GetRowCellValue(e.RowHandle, "manhinh").ToString();
                string tenuser = gridView1.GetRowCellValue(e.RowHandle, "tenuser").ToString();
                string chumay  = gridView1.GetRowCellValue(e.RowHandle, "chumay").ToString();
                string ghichu  = gridView1.GetRowCellValue(e.RowHandle, "ghichu").ToString();
                string maphong = gridView1.GetRowCellValue(e.RowHandle, "maphong").ToString();

                GridView view = sender as GridView;
                //kiểm tra xem dòng đang chọn có phải dòng mới không nếu đúng thì insert không thì update
                if (view.IsNewItemRow(e.RowHandle))
                {
                    try
                    {
                        string insert = "insert into PC values('" + tenmay + "','" + ram + "','" + chip + "','" + hdd + "','" + ssd + "',N'" + manhinh + "','" + tenuser + "',N'" + chumay + "',N'" + ghichu + "','" + maphong + "')";
                        Connect.Query(insert);
                        LoadData();
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thế kết nối tới CSDL!!");
                    }
                }
                else
                {
                    try
                    {
                        string update = "update PC set ram = '" + ram + "', chip = '" + chip + "', hdd = '" + hdd + "',ssd = '" + ssd + "', manhinh = N'" + manhinh + "', tenuser =N'" + tenuser + "' ,ghichu=N'" + ghichu + "', chumay = N'" + chumay + "' where tenmay = '" + tenmay + "' ";
                        Connect.Query(update);
                        LoadData();
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thế kết nối tới CSDL!!");
                    }
                }
            }
            else
            {
                DialogResult tb = XtraMessageBox.Show(sErr, "Lỗi trong quá trình Xuất!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (tb == DialogResult.OK)
                {
                    LoadData();
                }
            }
        }