示例#1
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            LoaiHangDTO a = new LoaiHangDTO();

            a.MaLoai  = txtMaLoai.Text;
            a.TenLoai = txtTenLoai.Text;
            a.GhiChu  = txtGhiChu.Text;

            if (txtMaLoai.Text == "")
            {
                MessageBox.Show("vui lòng nhập mã loại hàng muốn sửa");
            }
            else
            {
                try
                {
                    lhbus.UpdateLoaiHang(a);
                    MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    QL_LoaiHangGUI_Load(sender, e);
                    txtMaLoai.Focus();
                    txtMaLoai.Clear();
                    txtGhiChu.Clear();
                    txtTenLoai.Clear();
                }
                catch (SqlException)
                {
                    MessageBox.Show("Sửa thất bại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }
示例#2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            LoaiHangDTO a = new LoaiHangDTO();

            a.MaLoai  = txtMaLoai.Text;
            a.TenLoai = txtTenLoai.Text;
            a.GhiChu  = txtGhiChu.Text;


            try
            {
                lhbus.addLoaiHang(a);
                {
                    MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    QL_LoaiHangGUI_Load(sender, e);
                    txtMaLoai.Focus();
                    txtMaLoai.Clear();
                    txtGhiChu.Clear();
                    txtTenLoai.Clear();
                }
            }
            catch
            {
                MessageBox.Show("loai hang da ton tai nhap lai!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
示例#3
0
        public List <LoaiHangDTO> BangLoaiHang()
        {
            List <LoaiHangDTO> ds = new List <LoaiHangDTO>();

            KetNoiCoSoDuLieu.Moketnoi();
            string        SQlSL = "select *, lh.MaLoai as 'STT' from LoaiHang lh";
            SqlCommand    cmd   = new SqlCommand(SQlSL, KetNoiCoSoDuLieu.chuoiketnoi);
            SqlDataReader dr    = cmd.ExecuteReader();

            while (dr.Read())
            {
                LoaiHangDTO sp = new LoaiHangDTO(dr["STT"].ToString(), dr["MaLoai"].ToString(), dr["TenLoai"].ToString(), dr["GhiChu"].ToString());
                ds.Add(sp);
            }
            KetNoiCoSoDuLieu.Dongketnoi();
            return(ds);
        }
示例#4
0
        public static List <LoaiHangDTO> LayTatCaLoaiHangHoa()
        {
            List <LoaiHangDTO> lst = new List <LoaiHangDTO>();

            DataProvider p = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayTatCaLoaiHang", CommandType.StoredProcedure);

            LoaiHangDTO hh = null;

            while ((r.Read()))
            {
                hh           = new LoaiHangDTO();
                hh.MaLoaiHH  = Convert.ToInt32(r[0]);
                hh.TenLoaiHH = r[1].ToString();
                lst.Add(hh);
            }
            p.Disconnect();
            return(lst);
        }