Esempio n. 1
0
        private void butxoa_Click(object sender, EventArgs e)
        {
            if (txtmadg.Text == "")
            {
                MessageBox.Show("Chưa chọn thông tin");
                return;
            }
            docgia dg = new docgia();

            dg.madg     = txtmadg.Text;
            dg.tendg    = txttendg.Text;
            dg.ngaysinh = datengaysinh.Value;
            dg.diachi   = txtdiachi.Text;
            if (MessageBox.Show(string.Format("Xóa độc giả"), "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                if (Bus.DeleteProfile(dg) > 0)
                {
                    MessageBox.Show("Đã xóa");
                    Docgia_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("Thông tin chưa được xóa");
                }
            }
        }
Esempio n. 2
0
        private void butluu_Click(object sender, EventArgs e)
        {
            if (txtmadg.Text == "" || txttendg.Text == "")
            {
                MessageBox.Show("Chưa nhập đủ thông tin");
                return;
            }
            docgia dg = new docgia();

            dg.madg     = txtmadg.Text;
            dg.tendg    = txttendg.Text;
            dg.ngaysinh = datengaysinh.Value;
            dg.diachi   = txtdiachi.Text;
            if (MessageBox.Show(string.Format("Thêm độc giả"), "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                if (Bus.InsertProfile(dg) > 0)
                {
                    MessageBox.Show("Đã thêm");
                    Docgia_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("Lỗi");
                }
            }
        }
Esempio n. 3
0
        public bool Edit(docgia dg)
        {
            var obj = db.docgias.First(m => m.sothe == dg.sothe);

            if (obj != null)
            {
                try
                {
                    obj.hoten      = dg.hoten;
                    obj.ngaysinh   = dg.ngaysinh;
                    obj.gioitinh   = dg.gioitinh;
                    obj.email      = dg.email;
                    obj.diachi     = dg.diachi;
                    obj.socmtnd    = dg.socmtnd;
                    obj.ngaylamthe = dg.ngaylamthe;
                    obj.handungthe = dg.handungthe;
                    db.SubmitChanges();
                }
                catch (Exception)
                {
                    return(false);

                    throw;
                }
            }
            return(true);
        }
Esempio n. 4
0
        private void butsua_Click(object sender, EventArgs e)
        {
            if (txtmadg.Text == "" || txttendg.Text == "")
            {
                MessageBox.Show("Chưa nhập đủ thông tin");
                return;
            }
            docgia dg = new docgia();

            dg.madg   = txtmadg.Text;
            dg.tendg  = txttendg.Text;
            dg.diachi = txtdiachi.Text;
            if (MessageBox.Show(string.Format("Sửa độc giả "), "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                if (Bus.UpdateProfile(dg) > 0)
                {
                    MessageBox.Show("Đã sửa");
                    Docgia_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("Thông tin chưa được sửa");
                }
            }
        }
Esempio n. 5
0
        private void brnsua_Click(object sender, EventArgs e)
        {
            if (txtmadg.Text == "" || txttendg.Text == "")
            {
                MessageBox.Show("Chưa nhập đủ thông tin");
                return;
            }
            docgia dg = new docgia();

            dg.madg        = txtmadg.Text;
            dg.tendg       = txttendg.Text;
            dg.diachi      = txtdiachi.Text;
            dg.loaidg      = cbxloaidg.Text;
            dg.nganh       = cbxnganh.Text;
            dg.Lop         = cbxlop.Text;
            dg.khoahoc     = txtkhoahoc.Text;
            dg.ngaysinh    = datengaysinh.Value;
            dg.ngaycapnhat = datengaycapnhat.Value;

            if (MessageBox.Show(string.Format("Sửa độc giả "), "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                if (Bus.UpdateProfile(dg) > 0)
                {
                    MessageBox.Show("Đã sửa");
                    Docgia_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("Thông tin chưa được sửa");
                }
            }
        }
Esempio n. 6
0
 public static int DeleteProfile(docgia dg)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@ma", dg.madg),
         new SqlParameter("@ten", dg.tendg)
     };
     return(DataProvider.ExecuteNonQuery("xoadocgia", para));
 }
Esempio n. 7
0
 public static int UpdateProfile(docgia dg)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@ma", dg.madg),
         new SqlParameter("@ten", dg.tendg),
         new SqlParameter("@diachi", dg.diachi)
     };
     return(DataProvider.ExecuteNonQuery("suadocgia", para));
 }
Esempio n. 8
0
 public static int InsertProfile(docgia dg)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@ma", dg.madg),
         new SqlParameter("@ten", dg.tendg),
         new SqlParameter("@diachi", dg.diachi),
         new SqlParameter("@ngaysinh", dg.ngaysinh)
     };
     return(DataProvider.ExecuteNonQuery("themdocgia", para));
 }
Esempio n. 9
0
        private void Luu_DG_Click(object sender, EventArgs e)
        {
            if (Them_bool == true && Sua_bool == false)
            {
                var entity = new docgia();

                entity.sothe      = Convert.ToInt32(sothetxt.Text);
                entity.hoten      = tendgtxt.Text;
                entity.ngaysinh   = ngaysinhdg.Value;
                entity.gioitinh   = gioitinhdgtxt.Text;
                entity.diachi     = diachidgtxt.Text;
                entity.email      = emaildgtxt.Text;
                entity.socmtnd    = socmtnddgtxt.Text;
                entity.ngaylamthe = ngaythedg.Value;
                entity.handungthe = hanthedg.Value;

                var dg = new DocGiaController();
                if (dg.Add(entity) > 0)
                {
                    HienThi_DG();
                }
                else
                {
                    MessageBox.Show("Thêm độc giả không thành công");
                }
            }
            if (Them_bool == false && Sua_bool == true)
            {
                var entity = new docgia();
                entity.sothe      = Convert.ToInt32(sothetxt.Text);
                entity.hoten      = tendgtxt.Text;
                entity.ngaysinh   = ngaysinhdg.Value;
                entity.gioitinh   = gioitinhdgtxt.Text;
                entity.diachi     = diachidgtxt.Text;
                entity.email      = emaildgtxt.Text;
                entity.socmtnd    = socmtnddgtxt.Text;
                entity.ngaylamthe = ngaythedg.Value;
                entity.handungthe = hanthedg.Value;

                var dg = new DocGiaController();
                if (dg.Edit(entity))
                {
                    HienThi_DG();
                }
                else
                {
                    MessageBox.Show("Sửa độc giả không thành công");
                }
            }
            btn_enable(false);
        }
Esempio n. 10
0
        public int Add(docgia dg)
        {
            try
            {
                db.docgias.InsertOnSubmit(dg);
                db.SubmitChanges();
                return(dg.sothe);
            }
            catch (Exception)
            {
                return(0);

                throw;
            }
        }
Esempio n. 11
0
 public static int DeleteProfile(docgia dg)
 {
     return(Dao.DeleteProfile(dg));
 }
Esempio n. 12
0
 public static int UpdateProfile(docgia dg)
 {
     return(Dao.UpdateProfile(dg));
 }
Esempio n. 13
0
 public static int InsertProfile(docgia dg)
 {
     return(Dao.InsertProfile(dg));
 }