예제 #1
0
        private void loadDuLieu()
        {
            DataTable dt = CuaHangControl.layThongTin(MaCH);

            txtTenCu.Text    = dt.Rows[0]["TenCH"].ToString();
            txtDiaChiCu.Text = dt.Rows[0]["DiaChi"].ToString();
            txtSDTCu.Text    = dt.Rows[0]["SDT"].ToString();
        }
예제 #2
0
        private void loadDuLieu()
        {
            dgvDanhSach.Rows.Clear();
            DataTable dt = CuaHangControl.layDanhSach();

            for (int i = 0; i < dt.Rows.Count; ++i)
            {
                dgvDanhSach.Rows.Add(dt.Rows[i]["MaCH"], dt.Rows[i]["TenCH"], dt.Rows[i]["DiaChi"], dt.Rows[i]["SDT"]);
            }
        }
예제 #3
0
        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            string ten    = txtTenMoi.Text;
            string diachi = txtDiaChiMoi.Text;
            string sdt    = txtSDTMoi.Text;
            int    ketqua = CuaHangControl.suaDuLieu(MaCH, ten, diachi, sdt);

            if (ketqua > 0)
            {
                this.Close();
            }
        }
예제 #4
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            string ten    = txtTen.Text;
            string diachi = txtDiaChi.Text;
            string sdt    = txtSDT.Text;

            if (kiemTraDuLieu(ten, diachi, sdt))
            {
                int ketqua = CuaHangControl.themDuLieu(ten, diachi, sdt);
                if (ketqua > 0)
                {
                    this.Close();
                }
            }
        }
예제 #5
0
        private void timKiem()
        {
            string value = txtTimKiem.Text;

            if (value.Length == 0)
            {
                loadDuLieu();
                return;
            }
            dgvDanhSach.Rows.Clear();
            DataTable dt = CuaHangControl.timKiem(value);

            for (int i = 0; i < dt.Rows.Count; ++i)
            {
                dgvDanhSach.Rows.Add(dt.Rows[i]["MaCH"], dt.Rows[i]["TenCH"], dt.Rows[i]["DiaChi"], dt.Rows[i]["SDT"]);
            }
        }
예제 #6
0
        private void dgvDanhSach_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            int ma = Convert.ToInt32(dgvDanhSach.Rows[e.RowIndex].Cells["colMa"].Value.ToString());

            if (e.ColumnIndex == dgvDanhSach.Columns["colSua"].Index)
            {
                frmSuaCH frm = new frmSuaCH(ma);
                frm.ShowDialog();
                loadDuLieu();
            }
            else if (e.ColumnIndex == dgvDanhSach.Columns["colXoa"].Index)
            {
                int ketqua = CuaHangControl.xoaDuLieu(ma);
                if (ketqua > 0)
                {
                    loadDuLieu();
                }
            }
        }