コード例 #1
0
ファイル: CCTK.cs プロジェクト: thangben9x/IT-Iventory
 private void gridView1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         string       sohd = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "sohd").ToString();
         DialogResult tb   = XtraMessageBox.Show("Bạn có chắc chắn muốn xoá không?", "Chú ý", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (tb == DialogResult.Yes)
         {
             GridView view = sender as GridView;
             view.DeleteRow(view.FocusedRowHandle);
             try
             {
                 string delete = "delete from Nhap where sohd ='" + sohd + "' ";
                 Connect.Query(delete);
                 hien();
             }
             catch
             {
                 XtraMessageBox.Show("Lỗi! Hãy thử lại!");
                 hien();
             }
         }
         else
         {
             hien();
         }
     }
 }
コード例 #2
0
 private void gridView1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         string       tenmay = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "tenmay").ToString();
         DialogResult tb     = XtraMessageBox.Show("Bạn có chắc chắn muốn xoá không?", "Chú ý", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (tb == DialogResult.Yes)
         {
             try
             {
                 string delete = "delete from PC where tenmay ='" + tenmay + "'";
                 Connect.Query(delete);
                 LoadData();
             }
             catch
             {
                 XtraMessageBox.Show("Không thế kết nối tới CSDL!!");
             }
         }
         else
         {
             LoadData();
         }
     }
 }
コード例 #3
0
ファイル: Vattu.cs プロジェクト: thangben9x/IT-Iventory
        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, "model").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "tensp").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "dvt").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 dvt   = gridView1.GetRowCellValue(e.RowHandle, "dvt").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 VatTu values('" + model + "','" + tensp + "','" + dvt + "')";
                        Connect.Query(insert);
                        hien();
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thể kết nối tới CSDL!!");
                    }
                }
                else
                {
                    try
                    {
                        string update = "update VatTu set model = '" + model + "', tensp = '" + tensp + "',dvt = '" + dvt + "'";
                        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();
                }
            }
        }
コード例 #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, "tbthuhoi").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "model").ToString() == "" || gridView1.GetRowCellValue(e.RowHandle, "lydoth").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 tbthuhoi = gridView1.GetRowCellValue(e.RowHandle, "tbthuhoi").ToString();
                string stt      = gridView1.GetRowCellValue(e.RowHandle, "stt").ToString();
                string model    = gridView1.GetRowCellValue(e.RowHandle, "model").ToString();
                string lydoth   = gridView1.GetRowCellValue(e.RowHandle, "lydoth").ToString();
                string ghichu   = gridView1.GetRowCellValue(e.RowHandle, "ghichu").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 ThuHoi values('" + tenmay + "',N'" + tbthuhoi + "','" + model + "',N'" + lydoth + "',N'" + ghichu + "')";
                        Connect.Query(insert);
                        LoadData();
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thế kết nối tới CSDL!!");
                    }
                }
                else
                {
                    try
                    {
                        string update = "update ThuHoi set tenmay = '" + tenmay + "', tbthuhoi = N'" + tbthuhoi + "', model = '" + model + "',lydoth = N'" + lydoth + "', ghichu = N'" + ghichu + "' where stt = '" + stt + "' ";
                        Connect.Query(update);
                        LoadData();
                    }
                    catch
                    {
                        XtraMessageBox.Show("Không thế kết nối tới CSDL!!");
                    }
                }
            }
        }
コード例 #5
0
ファイル: CCTK.cs プロジェクト: thangben9x/IT-Iventory
        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();
                }
            }
        }
コード例 #6
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();
                }
            }
        }
コード例 #7
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();
                }
            }
        }