示例#1
0
 //hiển thị dữ liệu
 public void LoadDB(string sql)
 {
     Unity.OpenConnection();
     //truy xuất đến bản Khachang
     this.dataGridViewQLDMNV.DataSource = Unity.getDatatable(sql);
     this.dataGridViewQLDMNV.AutoResizeColumns();
 }
示例#2
0
        private void btn_them_Click(object sender, EventArgs e)
        {
            them = true;
            //khoi tao lai cac text
            this.txt_taikhoan.ResetText();
            this.cbx_VT.ResetText();
            this.txt_matkhau.ResetText();
            //khong Cho thao tác trên nút Thêm/Sửa/Xóa/Trở về.
            this.btn_them.Enabled  = false;
            this.btn_sua.Enabled   = false;
            this.btn_xoa.Enabled   = false;
            this.btn_trove.Enabled = false;
            //cho thao tác trên nút lưu, hũy
            this.btn_luu.Enabled      = true;
            this.btn_huybo.Enabled    = true;
            this.panel.Enabled        = true;
            this.txt_taikhoan.Enabled = true;
            //đưa dữ liệu lên combo box
            //lấy thứ tự record hiện hành
            int r = dataGridViewTK.CurrentCell.RowIndex;
            //tải dữ liệu vào bảng VT
            DataTable dt = new DataTable();

            Unity.OpenConnection();
            dt = Unity.getDatatable("select * from Nguoidung");
            this.cbx_VT.DataSource    = dt;
            this.cbx_VT.DisplayMember = "Vaitro";
            this.cbx_VT.ValueMember   = "Vaitro";
            this.cbx_VT.Text          = dataGridViewTK.Rows[r].Cells[2].Value.ToString();
            Unity.Close();
            //đua trỏ
            this.txt_taikhoan.Focus();
        }
示例#3
0
        private void btn_them_Click(object sender, EventArgs e)
        {
            them = true;
            //khoi tao lai cac text
            this.txt_diachi.ResetText();
            this.txt_dienthoai.ResetText();
            this.txt_maKH.ResetText();
            this.txt_tencongty.ResetText();
            this.cbx_thanhpho.ResetText();
            //khong Cho thao tác trên nút Thêm/Sửa/Xóa/Trở về.
            this.btn_them.Enabled  = false;
            this.btn_sua.Enabled   = false;
            this.btn_xoa.Enabled   = false;
            this.btn_trove.Enabled = false;
            //cho thao tác trên nút lưu, hũy
            this.btn_luu.Enabled   = true;
            this.btn_huybo.Enabled = true;
            this.panel.Enabled     = true;
            this.txt_maKH.Enabled  = true;
            //đưa dữ liệu lên combo box
            //tải dữ liệu vào bảng
            DataTable dt = new DataTable();

            Unity.OpenConnection();
            dt = Unity.getDatatable("select * from ThanhPho");
            this.cbx_thanhpho.DataSource = dt;
            //this.cbx_thanhpho.DisplayMember = "TenThanhPho";
            this.cbx_thanhpho.DisplayMember = "ThanhPho";
            this.cbx_thanhpho.ValueMember   = "ThanhPho";
            //đua trỏ
            this.txt_maKH.Focus();
        }
示例#4
0
        private void dataGridViewQLDMHD_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //lấy thứ tự record hiện hành
            int r = dataGridViewQLDMHD.CurrentCell.RowIndex;

            //lay gia tri tu luoi len cac text
            this.txt_maHD.Text = dataGridViewQLDMHD.Rows[r].Cells[0].Value.ToString();
            //lay gia tri combobox KH + NV
            //tải dữ liệu vào bảng KH
            DataTable dt = new DataTable();

            Unity.OpenConnection();
            dt = Unity.getDatatable("select * from KhachHang");
            this.cbx_MaKH.DataSource    = dt;
            this.cbx_MaKH.DisplayMember = "MaKH";
            this.cbx_MaKH.ValueMember   = "MaKH";
            this.cbx_MaKH.Text          = dataGridViewQLDMHD.Rows[r].Cells[1].Value.ToString();
            //tải dữ liệu vào bảng NV
            DataTable dt1 = new DataTable();

            Unity.OpenConnection();
            dt1 = Unity.getDatatable("select * from NhanVien");
            this.cbx_maNV.DataSource    = dt1;
            this.cbx_maNV.DisplayMember = "MaNV";
            this.cbx_maNV.ValueMember   = "MaNV";
            this.cbx_maNV.Text          = dataGridViewQLDMHD.Rows[r].Cells[2].Value.ToString();
            //lay gia tri tu luoi len cac text
            this.txt_ngaylap.Text  = dataGridViewQLDMHD.Rows[r].Cells[3].Value.ToString();
            this.txt_ngaynhan.Text = dataGridViewQLDMHD.Rows[r].Cells[4].Value.ToString();
            //đua trỏ
            this.txt_maHD.Focus();
        }
示例#5
0
 //hiển thị dữ liệu
 public void showData(string sql)
 {
     Unity.OpenConnection();
     //truy xuất đến bản Khachang
     dataGridViewDM.DataSource = Unity.getDatatable(sql);
     dataGridViewDM.AutoResizeColumns();
 }
示例#6
0
文件: Form2.cs 项目: tuongvyk4/KTPM
        private void button1_Click(object sender, EventArgs e)
        {
            if (validate()) //kiểm tra dữ liệu k rỗng thì :
            {               //khai báo chuỗi lệnh sql
                Unity.OpenConnection();
                string sql = "select * from NguoiDung where taikhoan = '" + txt_taikhoan.Text + "' and matkhau = '" + txt_matkhau.Text + "'";
                //MessageBox.Show("cau lenh: "+sql);
                DataTable data = Unity.getDatatable(sql);

                if (data.Rows.Count <= 0)   //gọi hàm getTable từ lớp có giá trị truyền vào là chuỗi lênh select để lấy thông tin từ bảng nếu có số dòng <= 0 thì:
                {
                    MessageBox.Show("Sai tài khoản hoặc mật khẩu!");
                    Unity.Close();
                }
                else  //nếu số dòng lấy được > 0 thì :
                {
                    //lay dữ liệu quyền cho form 1 (main)
                    Form1.quyen = data.Rows[0][2].ToString().Trim();

                    MessageBox.Show("quyen: " + Form1.quyen);
                    MessageBox.Show("Đăng nhập thành công!", "Thông báo!", MessageBoxButtons.OK);
                    Form1 f2 = new Form1();
                    this.Visible = false;
                    f2.ShowDialog();
                    Unity.Close();
                }
                //else
                //{
                //     MessageBox.Show("Sai thông tin đăng nhập!", "Cảnh báo!", MessageBoxButtons.OK);
            }
        }
示例#7
0
        private void dataGridViewQLDMCTHD_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //lấy thứ tự record hiện hành
            int r = dataGridViewQLDMCTHD.CurrentCell.RowIndex;

            //lay gia tri tu luoi len cac text
            this.txt_soluong.Text = dataGridViewQLDMCTHD.Rows[r].Cells[2].Value.ToString();
            //lay gia tri combobox HD + SP
            //tải dữ liệu vào bảng HD
            DataTable dt = new DataTable();

            Unity.OpenConnection();
            dt = Unity.getDatatable("select * from HoaDon");
            this.cbx_MaHD.DataSource    = dt;
            this.cbx_MaHD.DisplayMember = "MaHD";
            this.cbx_MaHD.ValueMember   = "MaHD";
            this.cbx_MaHD.Text          = dataGridViewQLDMCTHD.Rows[r].Cells[0].Value.ToString();
            //tải dữ liệu vào bảng SP
            DataTable dt1 = new DataTable();

            Unity.OpenConnection();
            dt1 = Unity.getDatatable("select * from SanPham");
            this.cbx_maSP.DataSource    = dt1;
            this.cbx_maSP.DisplayMember = "MaSP";
            this.cbx_maSP.ValueMember   = "MaSP";
            this.cbx_maSP.Text          = dataGridViewQLDMCTHD.Rows[r].Cells[1].Value.ToString();
            //đua trỏ
            this.cbx_MaHD.Focus();
        }
示例#8
0
        //hiển thị dữ liệu
        public void showData(string sql)
        {
            Unity.OpenConnection();
            //truy xuất đến bản Khachang
            dataGridViewQLDMTP.DataSource = Unity.getDatatable(sql);
            dataGridViewQLDMTP.AutoResizeColumns();

            //dataGridViewQLDMTP.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }
示例#9
0
        public FormQLKH_Theo_TP()
        {
            InitializeComponent();
            //đưa dữ liệu lên combo box
            //tải dữ liệu vào bảng
            DataTable dt = new DataTable();

            Unity.OpenConnection();
            dt = Unity.getDatatable("select TenThanhPho from ThanhPho");
            this.cbx_thanhpho.DataSource = dt;
            //this.cbx_thanhpho.DisplayMember = "TenThanhPho";
            this.cbx_thanhpho.DisplayMember = "TenThanhPho";
            this.cbx_thanhpho.ValueMember   = "TenThanhPho";
            //đua trỏ
        }
示例#10
0
        private Boolean Check(String taikhoan, String matkhau)
        {
            Unity.OpenConnection();
            string sql = "select * from NguoiDung where taikhoan = '" + taikhoan + "' and matkhau = '" + matkhau + "'";
            //MessageBox.Show("cau lenh: "+sql);
            DataTable data = Unity.getDatatable(sql);

            if (data.Rows.Count <= 0)  //gọi hàm getTable từ lớp có giá trị truyền vào là chuỗi lênh select để lấy thông tin từ bảng nếu có số dòng <= 0 thì:
            {
                Unity.Close();
                return(false);
            }
            else  //nếu số dòng lấy được > 0 thì :
            {
                Unity.Close();
                return(true);
            }
        }
示例#11
0
        private void btn_them_Click(object sender, EventArgs e)
        {
            them = true;

            //khoi tao lai cac text
            this.txt_maHD.ResetText();
            this.txt_ngaylap.ResetText();
            this.txt_ngaynhan.ResetText();
            this.cbx_MaKH.ResetText();
            this.cbx_maNV.ResetText();
            //khong Cho thao tác trên nút Thêm/Sửa/Xóa/Trở về.
            this.btn_them.Enabled  = false;
            this.btn_sua.Enabled   = false;
            this.btn_xoa.Enabled   = false;
            this.btn_trove.Enabled = false;
            //cho thao tác trên nút lưu, hũy
            this.btn_luu.Enabled   = true;
            this.btn_huybo.Enabled = true;
            this.panel.Enabled     = true;
            this.txt_maHD.Enabled  = true;
            //đưa dữ liệu lên combo box
            //lấy thứ tự record hiện hành
            int r = dataGridViewQLDMHD.CurrentCell.RowIndex;
            //tải dữ liệu vào bảng KH
            DataTable dt = new DataTable();

            Unity.OpenConnection();
            dt = Unity.getDatatable("select * from KhachHang");
            this.cbx_MaKH.DataSource    = dt;
            this.cbx_MaKH.DisplayMember = "MaKH";
            this.cbx_MaKH.ValueMember   = "MaKH";
            this.cbx_MaKH.Text          = dataGridViewQLDMHD.Rows[r].Cells[1].Value.ToString();
            //tải dữ liệu vào bảng NV
            DataTable dt1 = new DataTable();

            Unity.OpenConnection();
            dt1 = Unity.getDatatable("select * from NhanVien");
            this.cbx_maNV.DataSource    = dt1;
            this.cbx_maNV.DisplayMember = "MaNV";
            this.cbx_maNV.ValueMember   = "MaNV";
            this.cbx_maNV.Text          = dataGridViewQLDMHD.Rows[r].Cells[2].Value.ToString();
            //đua trỏ
            this.txt_maHD.Focus();
        }
示例#12
0
        private void btn_them_Click(object sender, EventArgs e)
        {
            them = true;
            //khoi tao lai cac text
            this.cbx_MaHD.ResetText();
            this.cbx_maSP.ResetText();
            this.txt_soluong.ResetText();
            //khong Cho thao tác trên nút Thêm/Sửa/Xóa/Trở về.
            this.btn_them.Enabled  = false;
            this.btn_sua.Enabled   = false;
            this.btn_xoa.Enabled   = false;
            this.btn_trove.Enabled = false;
            //cho thao tác trên nút lưu, hũy
            this.btn_luu.Enabled   = true;
            this.btn_huybo.Enabled = true;
            this.panel.Enabled     = true;
            this.cbx_MaHD.Enabled  = true;
            //đưa dữ liệu lên combo box
            //lấy thứ tự record hiện hành
            int r = dataGridViewQLDMCTHD.CurrentCell.RowIndex;
            //tải dữ liệu vào bảng HD
            DataTable dt = new DataTable();

            Unity.OpenConnection();
            dt = Unity.getDatatable("select * from HoaDon");
            this.cbx_MaHD.DataSource    = dt;
            this.cbx_MaHD.DisplayMember = "MaHD";
            this.cbx_MaHD.ValueMember   = "MaHD";
            this.cbx_MaHD.Text          = dataGridViewQLDMCTHD.Rows[r].Cells[0].Value.ToString();
            Unity.Close();
            //tải dữ liệu vào bảng SP
            DataTable dt1 = new DataTable();

            Unity.OpenConnection();
            dt1 = Unity.getDatatable("select * from SanPham");
            this.cbx_maSP.DataSource    = dt1;
            this.cbx_maSP.DisplayMember = "MaSP";
            this.cbx_maSP.ValueMember   = "MaSP";
            this.cbx_maSP.Text          = dataGridViewQLDMCTHD.Rows[r].Cells[1].Value.ToString();
            Unity.Close();
            //đua trỏ
            this.cbx_MaHD.Focus();
        }
示例#13
0
        private void dataGridViewTK_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //lấy thứ tự record hiện hành
            int r = dataGridViewTK.CurrentCell.RowIndex;

            //lay gia tri tu luoi len cac text
            this.txt_taikhoan.Text = dataGridViewTK.Rows[r].Cells[0].Value.ToString();
            this.txt_matkhau.Text  = dataGridViewTK.Rows[r].Cells[1].Value.ToString();
            //lay gia tri combobox Vai trò
            DataTable dt = new DataTable();

            Unity.OpenConnection();
            dt = Unity.getDatatable("select * from nguoidung");
            this.cbx_VT.DataSource    = dt;
            this.cbx_VT.DisplayMember = "Vaitro";
            this.cbx_VT.ValueMember   = "Vaitro";
            this.cbx_VT.Text          = dataGridViewTK.Rows[r].Cells[2].Value.ToString();
            //đua trỏ
            this.txt_taikhoan.Focus();
        }
示例#14
0
        private void dataGridViewQLDMKH_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //lấy thứ tự record hiện hành
            int r = dataGridViewQLDMKH.CurrentCell.RowIndex;

            //lay gia tri tu luoi len cac text
            this.txt_maKH.Text      = dataGridViewQLDMKH.Rows[r].Cells[0].Value.ToString();
            this.txt_diachi.Text    = dataGridViewQLDMKH.Rows[r].Cells[2].Value.ToString();
            this.txt_dienthoai.Text = dataGridViewQLDMKH.Rows[r].Cells[4].Value.ToString();
            this.txt_tencongty.Text = dataGridViewQLDMKH.Rows[r].Cells[1].Value.ToString();
            //this.txt_maKH.Enabled = false;
            //tải dữ liệu vào bảng
            DataTable dt = new DataTable();

            Unity.OpenConnection();
            dt = Unity.getDatatable("select * from ThanhPho");
            this.cbx_thanhpho.DataSource    = dt;
            this.cbx_thanhpho.DisplayMember = "ThanhPho";
            this.cbx_thanhpho.ValueMember   = "ThanhPho";
            //đua trỏ
            this.cbx_thanhpho.Text = dataGridViewQLDMKH.Rows[r].Cells[3].Value.ToString();
            this.txt_maKH.Focus();
        }