Esempio n. 1
0
        private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                GridView  view = sender as GridView;
                string    sql2 = @"select chumay, maphong from PC where tenmay = '" + view.GetRowCellValue(e.RowHandle, view.Columns[1]).ToString() + "' ";
                DataTable tb   = Connect.getTable(sql2);
                if (view == null)
                {
                    return;
                }

                if (e.Column.Caption != "Tên máy")
                {
                    return;
                }
                view.SetRowCellValue(e.RowHandle, view.Columns[6], "");
                string cellValue4 = "" + tb.Rows[0]["chumay"].ToString().Trim() + "" + view.GetRowCellValue(e.RowHandle, view.Columns[6]).ToString();
                view.SetRowCellValue(e.RowHandle, view.Columns[6], cellValue4);

                view.SetRowCellValue(e.RowHandle, view.Columns[7], "");
                string cellValue = "" + tb.Rows[0]["maphong"].ToString().Trim() + "" + view.GetRowCellValue(e.RowHandle, view.Columns[7]).ToString();
                view.SetRowCellValue(e.RowHandle, view.Columns[7], cellValue);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.ToString());
            }
        }
Esempio n. 2
0
        private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                GridView view = sender as GridView;
                // nếu cột không có giá trị thì trả về....
                if (view == null)
                {
                    return;
                }

                if (e.Column.Caption != "Tên máy")
                {
                    return;
                }

                string    sql2 = @"select chumay, maphong from PC where tenmay = '" + view.GetRowCellValue(e.RowHandle, view.Columns[0]).ToString() + "' ";
                DataTable tb   = Connect.getTable(sql2);

                view.SetRowCellValue(e.RowHandle, view.Columns[8], "");
                string cellValue4 = "" + tb.Rows[0]["chumay"].ToString().Trim() + "" + view.GetRowCellValue(e.RowHandle, view.Columns[8]).ToString();
                view.SetRowCellValue(e.RowHandle, view.Columns[8], cellValue4);

                view.SetRowCellValue(e.RowHandle, view.Columns[10], "");
                string cellValue = "" + tb.Rows[0]["maphong"].ToString().Trim() + "" + view.GetRowCellValue(e.RowHandle, view.Columns[10]).ToString();
                view.SetRowCellValue(e.RowHandle, view.Columns[10], cellValue);
            }
            catch
            {
                XtraMessageBox.Show("Có lỗi xảy ra !!");
            }
        }
Esempio n. 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string sql = "select *from  PhongBan";

            lookUpEdit1.Properties.DataSource    = Connect.getTable(sql);
            lookUpEdit1.Properties.DisplayMember = "tenphong";
            lookUpEdit1.Properties.ValueMember   = "maphong";
        }
Esempio n. 4
0
        private void CCTK_Load(object sender, EventArgs e)
        {
            hien();
            string sql1 = "select *from NhanVien";

            repositoryItemLookUpEdit1.DataSource    = Connect.getTable(sql1);
            repositoryItemLookUpEdit1.ValueMember   = "manv";
            repositoryItemLookUpEdit1.DisplayMember = "tennv";
        }
Esempio n. 5
0
        private void Fix_Update_Load(object sender, EventArgs e)
        {
            LoadData();
            string sql1 = "select *from PhongBan";

            repositoryItemLookUpEdit1.DataSource    = Connect.getTable(sql1);
            repositoryItemLookUpEdit1.ValueMember   = "tenphong";
            repositoryItemLookUpEdit1.DisplayMember = "maphong";
        }
Esempio n. 6
0
        private void Nhapmoi_Load(object sender, EventArgs e)
        {
            hien();
            //code chọn người nhập trong table. cột người nhập
            string sql1 = "select *from NhanVien";

            repositoryItemLookUpEdit1.DataSource    = Connect.getTable(sql1);
            repositoryItemLookUpEdit1.ValueMember   = "manv";
            repositoryItemLookUpEdit1.DisplayMember = "tennv";
            repositoryItemLookUpEdit1.NullText      = @"Chọn người nhập";
        }
Esempio n. 7
0
 private void LoadData()
 {
     try
     {
         string sql = "select stt, ThuHoi.tenmay, chumay, maphong, tbthuhoi, model, lydoth, ThuHoi.ghichu from ThuHoi inner join PC on PC.tenmay = ThuHoi.tenmay order by stt desc";
         gridControl1.DataSource = Connect.getTable(sql);
     }
     catch
     {
         MessageBox.Show("Không thể kết nối tới CSDL!!");
     }
 }
Esempio n. 8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            hien();
            string sql = "select *from  PhongBan";

            lookUpEdit1.Properties.DataSource    = Connect.getTable(sql);
            lookUpEdit1.Properties.DisplayMember = "tenphong";
            lookUpEdit1.Properties.ValueMember   = "maphong";
            timer1.Start();
            barStaticItem1.Caption = DateTime.Now.ToLongTimeString();
            barStaticItem2.Caption = DateTime.Now.ToLongDateString();
        }
Esempio n. 9
0
 private void Loaddt()
 {
     try
     {
         string sql = "SELECT Tonct.model, Tonct.tensp, Tonct.Barcode ,sum(Tonct.Tondk) AS TonDau, sum(Tonct.Nhaptk) AS Nhap, sum(Tonct.Xuattk) AS Xuat, (sum(Tonct.Tondk)+sum(Tonct.Nhaptk)- sum(Tonct.Xuattk)) AS TonCuoi  FROM(Select dk.model, dk.tensp, dk.Barcode, Tondk, 0 as Nhaptk, 0 as Xuattk  From (Select a.model, a.tensp, a.Barcode, (Sum(a.Nhap) - Sum(a.Xuat)) AS Tondk  From (Select N.model, H.tensp, H.dvt as Barcode, Sum(N.slnhap) as Nhap, 0 as Xuat  From Nhap N, VatTu H Where N.model = H.model and N.ngaynhap < '" + Convert.ToDateTime(ngaybd.Text).ToString("MM/dd/yyyy") + "'  Group By N.model, H.tensp, H.dvt UNION (Select X.model, H.tensp, H.dvt as Barcode, 0 as Nhap, sum(X.slxuat) as Xuat From Xuat X, VatTu H Where X.model = H.model and X.ngayxuat < '" + Convert.ToDateTime(ngaybd.Text).ToString("MM/dd/yyyy") + "' Group By X.model, H.tensp, H.dvt)) a GROUP BY a.model, a.tensp, a.Barcode HAVING(Sum(a.Nhap - a.Xuat)) <> 0) dk Union Select model, tensp, dvt as Barcode, 0 as Tondk, 0 as Nhaptk, 0 as Xuattk From VatTu Union Select N.model, H.tensp, H.dvt as Barcode, 0 as Tondk, Sum(N.slnhap) as Nhaptk, 0 as Xuattk  From Nhap N, VatTu H Where N.model = H.model and N.ngaynhap >= '" + Convert.ToDateTime(ngaybd.Text).ToString("MM/dd/yyyy") + "' and N.ngaynhap <= '" + Convert.ToDateTime(ngaykt.Text).ToString("MM/dd/yyyy") + "'  Group By N.model, H.tensp, H.dvt Union Select X.model, H.tensp, H.dvt as Barcode, 0 as Tondk, 0 as Nhaptk, sum(X.slxuat) as Xuattk  From Xuat X, VatTu H Where X.model = H.model and X.ngayxuat >= '" + Convert.ToDateTime(ngaybd.Text).ToString("MM/dd/yyyy") + "' and X.ngayxuat <= '" + Convert.ToDateTime(ngaykt.Text).ToString("MM/dd/yyyy") + "'  Group By X.model, H.tensp, H.dvt )  AS Tonct GROUP BY Tonct.model, Tonct.tensp, Tonct.Barcode HAVING(sum(Tonct.Tondk) + sum(Tonct.Nhaptk) - sum(Tonct.Xuattk)) <> 0";
         gridControl1.DataSource = Connect.getTable(sql);
     }
     catch
     {
         XtraMessageBox.Show("Không kết nối được tới CSDL!!");
     }
 }
Esempio n. 10
0
 private void LoadData()
 {
     try
     {
         string sql = "select tenmay, ram, chip, hdd, ssd, manhinh, tenuser, chumay, ghichu, maphong from PC where maphong ='" + map + "'";
         gridControl1.DataSource = Connect.getTable(sql);
     }
     catch
     {
         XtraMessageBox.Show("Không thể kết nối tới CSDL!!");
     }
 }
Esempio n. 11
0
 private void Loaddata()
 {
     try
     {
         string sql = "select MaVT, TenVT, dvt, Sum(Nhap) as tongnhhap , SUM(Xuat) as tongxuat, (SUM(Nhap) - SUM(Xuat)) as Ton from (select model as MaVT, tensp as TenVT, dvt as dvt, 0 as Nhap, 0 as Xuat From VatTu union Select N.model as MaVT, H.tensp as TenVT, H.dvt as dvt, Sum(N.slnhap) as Nhap, 0 as Xuat  From Nhap N, VatTu H Where N.model = H.model  Group By N.model, H.tensp, H.dvt having SUM(N.slnhap) > 0 union Select X.model as MaVT, H.tensp as TenVT, H.dvt as dvt, 0 as Nhap, Sum(X.slxuat) as Xuat   From Xuat X, VatTu H Where X.model = H.model Group By X.model, H.tensp, H.dvt having SUM(X.slxuat) > 0 ) as hangton Group by MaVT, TenVT, dvt";
         gridControl1.DataSource = Connect.getTable(sql);
     }
     catch
     {
         XtraMessageBox.Show("Không thể kết nối tới CSDL");
     }
 }
Esempio n. 12
0
        private void hien()
        {
            try
            {
                string sql = "select NhanVien.* from NhanVien";



                gridControl1.DataSource = Connect.getTable(sql);
            }
            catch
            {
                XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 13
0
        private void hien()
        {
            try
            {
                string sql = "SELECT Nhap.masp, Nhap.slnhap, Nhap.ngaynhap, Nhap.sn, Nhap.barcode, Nhap.ncc, Nhap.ghichu, Nhap.sohd, VatTu.tensp, VatTu.dvt, VatTu.model, NhanVien.manv FROM NhanVien INNER JOIN Nhap ON NhanVien.manv = Nhap.manv INNER JOIN VatTu ON Nhap.model = VatTu.model order by sohd desc";



                gridControl1.DataSource = Connect.getTable(sql);
            }
            catch
            {
                XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 14
0
        private void hien()
        {
            try
            {
                string sql = "SELECT Xuat.masp, Xuat.slxuat, Xuat.ngayxuat, Xuat.sn, Xuat.barcode, Xuat.ncc, Xuat.ghichu, Xuat.sohd, VatTu.model, VatTu.tensp, VatTu.dvt, NhanVien.manv FROM Xuat INNER JOIN VatTu ON Xuat.model = VatTu.model INNER JOIN  NhanVien ON Xuat.manv = NhanVien.manv";

                gridControl1.DataSource = Connect.getTable(sql);

            }
            catch
            {
                XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }


        }
Esempio n. 15
0
 private void hien()
 {
     try
     {
         string sql1 = "select MaVT, TenVT, dvt, Sum(Nhap) as tongnhhap , SUM(Xuat) as tongxuat, (SUM(Nhap) - SUM(Xuat)) as Ton from (select model as MaVT, tensp as TenVT, dvt as dvt, 0 as Nhap, 0 as Xuat From VatTu union Select N.model as MaVT, H.tensp as TenVT, H.dvt as dvt, Sum(N.slnhap) as Nhap, 0 as Xuat  From Nhap N, VatTu H Where N.model = H.model  Group By N.model, H.tensp, H.dvt having SUM(N.slnhap) > 0 union Select X.model as MaVT, H.tensp as TenVT, H.dvt as dvt, 0 as Nhap, Sum(X.slxuat) as Xuat   From Xuat X, VatTu H Where X.model = H.model Group By X.model, H.tensp, H.dvt having SUM(X.slxuat) > 0 ) as hangton Group by MaVT, TenVT, dvt";
         chart1.DataSource = Connect.getTable(sql1);
         chart1.ChartAreas["ChartArea1"].AxisY.Title  = "Tổng Số Lượng Nhập Xuất";
         chart1.ChartAreas["ChartArea1"].AxisX.Title  = "Mã Model";
         chart1.Series["Tổng Xuất Kho"].XValueMember  = "MaVT";
         chart1.Series["Tổng Xuất Kho"].YValueMembers = "tongxuat";
         chart1.Series["Tổng Nhập Kho"].YValueMembers = "tongnhhap";
         chart1.Series["Tồn Kho"].YValueMembers       = "Ton";
     }
     catch
     {
         XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 16
0
 // Xuất ra file exel
 private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     try
     {
         string         sql3 = "SELECT Nhap.masp, Nhap.slnhap, Nhap.ngaynhap, Nhap.sn, Nhap.barcode, Nhap.ncc, Nhap.ghichu, Nhap.sohd, VatTu.tensp, VatTu.dvt, VatTu.model, NhanVien.manv FROM NhanVien INNER JOIN Nhap ON NhanVien.manv = Nhap.manv INNER JOIN VatTu ON Nhap.model = VatTu.model order by sohd desc";
         SaveFileDialog saveFileDialogExcel = new SaveFileDialog();
         saveFileDialogExcel.Filter = "Excel files (*.xlsx)|*.xlsx";
         if (saveFileDialogExcel.ShowDialog() == DialogResult.OK)
         {
             string exportFilePath = saveFileDialogExcel.FileName;
             gridControl1.DataSource = Connect.getTable(sql3);
             gridControl1.ExportToXlsx(exportFilePath);
             XtraMessageBox.Show("Xuất file Excel thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch
     {
         XtraMessageBox.Show("Không thể Xuất file Excel", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 17
0
        private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                //blinding dữ liệu tương ứng từ cột mã loại khi nhập vào các cell mã vật tư, tên vt, loại từ bảng Vật tư
                GridView view = sender as GridView;
                // nếu cột không có giá trị thì trả về....
                if (view == null)
                {
                    return;
                }
                {
                    switch (e.Column.Caption.ToString())
                    {
                    case "Model":
                        string sql2 = @"select tensp,dvt from VatTu where model = '" + view.GetRowCellValue(e.RowHandle, view.Columns[0]).ToString() + "' ";
                        // thực thi câu lệnh sql thành dạng bảng
                        DataTable tb = Connect.getTable(sql2);
                        //blinding dvt
                        view.SetRowCellValue(e.RowHandle, view.Columns[2], "");
                        string cellValue2 = "" + tb.Rows[0]["dvt"].ToString().Trim() + "" + view.GetRowCellValue(e.RowHandle, view.Columns[2]).ToString();
                        view.SetRowCellValue(e.RowHandle, view.Columns[2], cellValue2);



                        //blinding tenvt
                        view.SetRowCellValue(e.RowHandle, view.Columns[1], "");
                        string cellValue1 = "" + tb.Rows[0]["tensp"].ToString().Trim() + "" + view.GetRowCellValue(e.RowHandle, view.Columns[1]).ToString();
                        view.SetRowCellValue(e.RowHandle, view.Columns[1], cellValue1);
                        break;
                    }
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu nhập!!");
            }
        }
Esempio n. 18
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);
        }