Example #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            ET_GianHang et_GianHang = null;

            try
            {
                et_GianHang = new ET_GianHang(txtMaGH.Text
                                              , txtTenGH.Text
                                              , Int32.Parse(txtSoLuong.Text));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Kiểu dữ liệu bạn nhập bị sai.Vui lòng nhập lại");
                return;
            }

            if (bus_GH.themGH(et_GianHang))
            {
                dgvGiangHang.DataSource = bus_GH.getGH();
                MessageBox.Show("Bạn Đã thêm thành công.");
            }
            else
            {
                MessageBox.Show("Bạn thêm không thành công.");
            }
        }
Example #2
0
        //----------------------------------------------------------------
        //HAM PHU
        public void addParameter(SqlCommand cmd, ET_GianHang gianHang, String[] strNameParametor)
        { //MaGH, TenGH, SoLuongSach
            ArrayList list = gianHang.getAllProperties();

            foreach (string item in strNameParametor)
            {
                SqlParameter pt = new SqlParameter(item, list[Array.IndexOf(strNameParametor, item)]);
                cmd.Parameters.Add(pt);
            }
        }
Example #3
0
        private void dgvGiangHang_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow item = dgvGiangHang.SelectedRows[0];

            if (item.Index >= dgvGiangHang.RowCount - 1)
            {
                MessageBox.Show("Không tìm thấy dữ liệu bạn chọn.Vui lòng chọn lại");
                return;
            }
            ET_GianHang et_GH = null;

            et_GH           = new ET_GianHang(item.Cells[0].Value.ToString(), item.Cells[1].Value.ToString(), int.Parse(item.Cells[2].Value.ToString()));
            txtMaGH.Text    = et_GH.MaGH;
            txtTenGH.Text   = et_GH.TenGH;
            txtSoLuong.Text = et_GH.SoLuongSach.ToString();
        }
Example #4
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            ET_GianHang et_GianHang = null;

            try
            {
                et_GianHang = new ET_GianHang(txtMaGH.Text
                                              , txtTenGH.Text
                                              , Int32.Parse(txtSoLuong.Text));
            }
            catch (InvalidCastException ex)
            {
                MessageBox.Show("Kiểu dữ liệu bạn nhập bị sai.Vui lòng nhập lại");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Dữ liệu bạn hiện đang trống");
                return;
            }

            DialogResult r = MessageBox.Show("Bạn có muốn sữa dữ liệu này không", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (r == DialogResult.No)
            {
                MessageBox.Show("Bạn đã hủy sữa");
                return;
            }

            if (bus_GH.suaGH(et_GianHang))
            {
                dgvGiangHang.DataSource = bus_GH.getGH();
                MessageBox.Show("Bạn Đã sữa thành công.");
            }
            else
            {
                MessageBox.Show("Bạn sữa không thành công.");
            }
        }
Example #5
0
        public bool suaGH(ET_GianHang et_GH)
        {
            try
            {
                openDB();
                SqlCommand cmd = HandleCMD.proc("sp_SuaGH", _con);
                addParameter(cmd, et_GH, strNameParametor);

                if (this.cmdExecuted(cmd))
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                closeDB();
            }
            return(false);
        }
Example #6
0
 public bool suaGH(ET_GianHang et_GH)
 {
     return(dal_GH.suaGH(et_GH));
 }
Example #7
0
 public bool themGH(ET_GianHang et_GH)
 {
     return(dal_GH.themGH(et_GH));
 }