Example #1
0
        public bool deletedata(En_SanPham en)
        {
            string query = string.Format("DELETE FROM SanPham WHERE MaHang=@MaHang");

            SqlParameter[] sqlPara = new SqlParameter[1];
            sqlPara[0] = new SqlParameter("@MaHang", en.MaHang);
            return(cnn.executeDeleteQuery(query, sqlPara));
        }
Example #2
0
        public bool updatedata(En_SanPham en)
        {
            string query = string.Format("UPDATE SanPham SET TenHang=@TenHang, SoLuong=@SoLuong, GiaBan=@GiaBan WHERE MaHang=@MaHang");

            SqlParameter[] sqlPara = new SqlParameter[4];
            sqlPara[0] = new SqlParameter("@TenHang", en.TenHang);
            sqlPara[1] = new SqlParameter("@SoLuong", en.SoLuong);
            sqlPara[2] = new SqlParameter("@GiaBan", en.GiaBan);
            sqlPara[3] = new SqlParameter("@MaHang", en.MaHang);
            return(cnn.executeUpdateQuery(query, sqlPara));
        }
Example #3
0
        public bool insertdata(En_SanPham en)
        {
            string query = string.Format("INSERT INTO SanPham(MaHang, TenHang, SoLuong, GiaBan, MaLoai) VALUES(@MaHang,@TenHang,@SoLuong,@GiaBan,@MaLoai)");

            SqlParameter[] sqlPara = new SqlParameter[5];
            sqlPara[0] = new SqlParameter("@MaHang", en.MaHang);
            sqlPara[1] = new SqlParameter("@TenHang", en.TenHang);
            sqlPara[2] = new SqlParameter("@SoLuong", en.SoLuong);
            sqlPara[3] = new SqlParameter("@GiaBan", en.GiaBan);
            sqlPara[4] = new SqlParameter("@MaLoai", en.MaLoai);
            return(cnn.executeInsertQuery(query, sqlPara));
        }
Example #4
0
        //End Controls

        public Form1()
        {
            InitializeComponent();

            //Set up the form.
            this.MaximizeBox     = false;
            this.MinimizeBox     = false;
            this.Size            = new System.Drawing.Size(600, 400);
            this.Text            = "Quản lý sản phẩm theo loại";
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.StartPosition   = FormStartPosition.CenterScreen;

            //ComboBox
            this.cboLoaiSP.Location = new System.Drawing.Point(94, 12);
            this.cboLoaiSP.Size     = new System.Drawing.Size(200, 21);
            //End ComboBox

            //Label
            this.lbl1.Text     = "Loại sản phẩm";
            this.lbl1.Location = new System.Drawing.Point(12, 15);
            this.lbl1.Size     = new System.Drawing.Size(76, 13);

            this.lbl2.Text     = "Thông tin sản phẩm dựa vào loại sản phẩm đã chọn";
            this.lbl2.Location = new System.Drawing.Point(12, 36);
            this.lbl2.Size     = new System.Drawing.Size(254, 13);

            this.lbl3.Text     = "Mã sản phẩm:";
            this.lbl3.Location = new System.Drawing.Point(16, 251);
            this.lbl3.Size     = new System.Drawing.Size(74, 13);

            this.lbl4.Text     = "Tên sản phẩm:";
            this.lbl4.Location = new System.Drawing.Point(12, 277);
            this.lbl4.Size     = new System.Drawing.Size(78, 13);

            this.lbl5.Text     = "Số lượng";
            this.lbl5.Location = new System.Drawing.Point(12, 277);
            this.lbl5.Size     = new System.Drawing.Size(49, 13);

            this.lbl6.Text     = "Giá bán:";
            this.lbl6.Location = new System.Drawing.Point(145, 302);
            this.lbl6.Size     = new System.Drawing.Size(47, 13);
            //End Label

            //DataGridView
            this.dgv.AllowUserToAddRows    = false;
            this.dgv.AllowUserToDeleteRows = false;
            this.dgv.ReadOnly      = true;
            this.dgv.MultiSelect   = false;
            this.dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.dgv.Location      = new System.Drawing.Point(15, 52);
            this.dgv.Size          = new System.Drawing.Size(557, 190);
            //End DataGridView

            //NumericUpDown
            this.nud.Minimum  = 0;
            this.nud.Maximum  = 999999;
            this.nud.Location = new System.Drawing.Point(89, 300);
            this.nud.Size     = new System.Drawing.Size(50, 20);
            //End NumericUpDown

            //Textbox
            this.txtMaSP.Location = new System.Drawing.Point(89, 248);
            this.txtMaSP.Size     = new System.Drawing.Size(100, 20);

            this.txtTenSP.Location = new System.Drawing.Point(89, 274);
            this.txtTenSP.Size     = new System.Drawing.Size(300, 20);

            this.txtGiaBan.Location = new System.Drawing.Point(198, 300);
            this.txtGiaBan.Size     = new System.Drawing.Size(191, 20);
            //End Textbox

            //Button
            this.btnThem.Text     = "Thêm";
            this.btnThem.Location = new System.Drawing.Point(173, 327);
            this.btnThem.Size     = new System.Drawing.Size(75, 23);

            this.btnSua.Text     = "Sửa";
            this.btnSua.Location = new System.Drawing.Point(254, 326);
            this.btnSua.Size     = new System.Drawing.Size(75, 23);

            this.btnXoa.Text     = "Xóa";
            this.btnXoa.Location = new System.Drawing.Point(335, 327);
            this.btnXoa.Size     = new System.Drawing.Size(75, 23);

            this.btnHuy.Text     = "Hủy";
            this.btnHuy.Location = new System.Drawing.Point(416, 327);
            this.btnHuy.Size     = new System.Drawing.Size(75, 23);

            this.btnLuu.Text     = "Lưu";
            this.btnLuu.Location = new System.Drawing.Point(497, 327);
            this.btnLuu.Size     = new System.Drawing.Size(75, 23);
            //End Button

            this.Controls.Add(cboLoaiSP);

            this.Controls.Add(lbl1);
            this.Controls.Add(lbl2);
            this.Controls.Add(lbl3);
            this.Controls.Add(lbl4);
            this.Controls.Add(lbl5);
            this.Controls.Add(lbl6);

            this.Controls.Add(dgv);

            this.Controls.Add(nud);

            this.Controls.Add(txtMaSP);
            this.Controls.Add(txtTenSP);
            this.Controls.Add(txtGiaBan);

            this.Controls.Add(btnThem);
            this.Controls.Add(btnSua);
            this.Controls.Add(btnXoa);
            this.Controls.Add(btnHuy);
            this.Controls.Add(btnLuu);

            en = new En_SanPham();

            NapLoaiSP();
            NapSanPham();
            EvenButton(0);
            EnableOrDisable(true);

            this.cboLoaiSP.SelectedIndexChanged += new System.EventHandler(this.cboLoaiSP_SelectedIndexChange);
            this.dgv.Click += new System.EventHandler(this.dgv_SelectedIndexChange);

            this.btnThem.Click += new System.EventHandler(this.btnThem_Click);
            this.btnSua.Click  += new System.EventHandler(this.btnSua_Click);
            this.btnXoa.Click  += new System.EventHandler(this.btnXoa_Click);
            this.btnHuy.Click  += new System.EventHandler(this.btnHuy_Click);
            this.btnLuu.Click  += new System.EventHandler(this.btnLuu_Click);
        }
Example #5
0
 public void deletedata(En_SanPham en)
 {
     dal.deletedata(en);
 }
Example #6
0
 public void updatedata(En_SanPham en)
 {
     dal.updatedata(en);
 }
Example #7
0
 public void insertdata(En_SanPham en)
 {
     dal.insertdata(en);
 }