Example #1
0
        public int deletedata(En_LoaiSanPham en)
        {
            string query = string.Format("DELETE FROM LoaiSanPham WHERE MaLoai=@MaLoai");

            SqlParameter[] sqlPara = new SqlParameter[1];
            sqlPara[0] = new SqlParameter("@MaLoai", en.MaLoai);
            int rows = 0;

            try
            {
                cnn.executeDeleteQuery(query, sqlPara);
                rows += 1;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(rows);
        }
Example #2
0
        public int insertdata(En_LoaiSanPham en)
        {
            string query = string.Format("INSERT INTO LoaiSanPham(TenLoai, MoTa) VALUES(@TenLoai,@MoTa)");

            SqlParameter[] sqlPara = new SqlParameter[2];
            sqlPara[0] = new SqlParameter("@TenLoai", en.TenLoai);
            sqlPara[1] = new SqlParameter("@MoTa", en.MoTa);
            int rows = 0;

            try
            {
                cnn.executeInsertQuery(query, sqlPara);
                rows += 1;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(rows);
        }
Example #3
0
        public int updatedata(En_LoaiSanPham en)
        {
            string query = string.Format("UPDATE LoaiSanPham SET TenLoai=@TenLoai, MoTa=@MoTa WHERE MaLoai=@MaLoai");

            SqlParameter[] sqlPara = new SqlParameter[3];
            sqlPara[0] = new SqlParameter("@TenLoai", en.TenLoai);
            sqlPara[1] = new SqlParameter("@MoTa", en.MoTa);
            sqlPara[2] = new SqlParameter("@MaLoai", en.MaLoai);
            int rows = 0;

            try
            {
                cnn.executeUpdateQuery(query, sqlPara);
                rows += 1;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(rows);
        }
Example #4
0
 public void deletedata(En_LoaiSanPham en)
 {
     dal.deletedata(en);
 }
Example #5
0
 public void updatedata(En_LoaiSanPham en)
 {
     dal.updatedata(en);
 }
Example #6
0
 public void insertdata(En_LoaiSanPham en)
 {
     dal.insertdata(en);
 }
Example #7
0
        //End Controls
        public Form1()
        {
            InitializeComponent();

            //Set up the form.
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            //this.BackColor = Color.White;
            //this.ForeColor = Color.Black;
            this.Size            = new System.Drawing.Size(435, 300);
            this.Text            = "Loại sản phẩm";
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.StartPosition   = FormStartPosition.CenterScreen;

            //Label
            this.lblMaLoai.Text     = "Mã loại";
            this.lblMaLoai.Location = new System.Drawing.Point(12, 15);
            this.lblMaLoai.Size     = new System.Drawing.Size(41, 13);

            this.lblTenLoai.Text     = "Tên loại";
            this.lblTenLoai.Location = new System.Drawing.Point(115, 15);
            this.lblTenLoai.Size     = new System.Drawing.Size(45, 13);

            this.lblMoTa.Text     = "Mô tả";
            this.lblMoTa.Location = new System.Drawing.Point(272, 15);
            this.lblMoTa.Size     = new System.Drawing.Size(34, 13);
            //End Label

            //Textbox
            //this.txtMaLoai.Text = "Text";
            this.txtMaLoai.Location = new System.Drawing.Point(59, 12);
            this.txtMaLoai.Size     = new System.Drawing.Size(50, 20);
            this.txtMaLoai.Enabled  = false;

            //this.txtTenLoai.Text = "Text";
            this.txtTenLoai.Location = new System.Drawing.Point(166, 12);
            this.txtTenLoai.Size     = new System.Drawing.Size(100, 20);

            //this.txtMoTa.Text = "Text";
            this.txtMoTa.Location = new System.Drawing.Point(312, 12);
            this.txtMoTa.Size     = new System.Drawing.Size(100, 20);
            //End Textbox

            //Button
            this.btnThemMoi.Text     = "Thêm mới";
            this.btnThemMoi.Location = new System.Drawing.Point(15, 38);
            this.btnThemMoi.Size     = new System.Drawing.Size(75, 23);

            this.btnCapNhat.Text     = "Cập nhật";
            this.btnCapNhat.Location = new System.Drawing.Point(96, 38);
            this.btnCapNhat.Size     = new System.Drawing.Size(75, 23);

            this.btnXoa.Text     = "Xóa";
            this.btnXoa.Location = new System.Drawing.Point(177, 38);
            this.btnXoa.Size     = new System.Drawing.Size(75, 23);
            //End Button

            //Listview
            this.listView1.MultiSelect = false;
            this.listView1.Location    = new System.Drawing.Point(15, 67);
            this.listView1.Size        = new System.Drawing.Size(237, 188);
            //End Listview

            this.Controls.Add(lblMaLoai);
            this.Controls.Add(lblTenLoai);
            this.Controls.Add(lblMoTa);

            this.Controls.Add(txtMaLoai);
            this.Controls.Add(txtTenLoai);
            this.Controls.Add(txtMoTa);

            this.Controls.Add(btnThemMoi);
            this.Controls.Add(btnCapNhat);
            this.Controls.Add(btnXoa);

            this.Controls.Add(listView1);

            en = new En_LoaiSanPham();

            LoadData();

            listView1.Click += new System.EventHandler(this.listView1_SelectedIndexChange);

            btnThemMoi.Click += new System.EventHandler(this.btnThemMoi_Click);
            btnCapNhat.Click += new System.EventHandler(this.btnCapNhat_Click);
            btnXoa.Click     += new System.EventHandler(this.btnXoa_Click);
        }