private void btnthemkm_Click(object sender, EventArgs e)
        {
            eKhuyenMai k = new eKhuyenMai();

            k.ghiChu   = txtghiChukm.Text;
            k.msDotKM  = txtMaSoDotKhuyenMai.Text;
            k.ngayBD   = Convert.ToDateTime(dtpngaybatdaukm.Text);
            k.ngayKT   = Convert.ToDateTime(dtpngayketthuckm.Text);
            k.tenDotKM = txtghiChukm.Text;
            int m = kmbll.themKM(k);

            if (m == 0)
            {
                MessageBox.Show("Trùng mã !", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
            else
            {
                if (m == 1)
                {
                    MessageBox.Show("Thêm thành công !", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                }
                dgvkhuyenmai.DataSource   = kmbll.getAllKM();
                dgvctkhuyenmai.DataSource = kmbll.getAllCTKM();
            }
            btnthemkm.Enabled = true;
        }
 private void dgvkhuyenmai_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
 {
     if (dgvkhuyenmai.SelectedRows.Count > 0)
     {
         eKhuyenMai ekm = (eKhuyenMai)bds2.Current;
         txtMaSoDotKhuyenMai.Text = e.Row.Cells["msDotKM"].Value.ToString();
         cmbmsDotKm.Text          = e.Row.Cells["msDotKM"].Value.ToString();
         dtpngaybatdaukm.Text     = e.Row.Cells["ngayBD"].Value.ToString();
         dtpngayketthuckm.Text    = e.Row.Cells["ngayKT"].Value.ToString();
         txtTenDotKhuyenMai.Text  = e.Row.Cells["tenDotKM"].Value.ToString();
         txtghiChukm.Text         = e.Row.Cells["ghiChu"].Value.ToString();
     }
 }
示例#3
0
        public List <eKhuyenMai> getAllKM()
        {
            var km = db.Tbl_KhuyenMais.ToList();
            List <eKhuyenMai> kq = new List <eKhuyenMai>();

            foreach (Tbl_KhuyenMai tmp in km)
            {
                eKhuyenMai newkm = new eKhuyenMai();
                newkm.ghiChu   = tmp.ghiChu;
                newkm.msDotKM  = tmp.msDotKM;
                newkm.ngayBD   = tmp.ngayBD;
                newkm.ngayKT   = tmp.ngayKT;
                newkm.tenDotKM = tmp.tenDotKM;
                kq.Add(newkm);
            }
            return(kq);
        }
示例#4
0
        public int themKM(eKhuyenMai km)
        {
            var tkm = db.Tbl_KhuyenMais.Where(x => x.msDotKM == km.msDotKM).FirstOrDefault();

            if (tkm != null)
            {
                return(0);
            }
            Tbl_KhuyenMai p = new Tbl_KhuyenMai();

            p.msDotKM  = km.msDotKM;
            p.tenDotKM = km.tenDotKM;
            p.ngayBD   = km.ngayBD;
            p.ngayKT   = km.ngayKT;
            p.ghiChu   = km.ghiChu;
            db.Tbl_KhuyenMais.InsertOnSubmit(p);
            db.SubmitChanges();
            return(1);
        }