Esempio n. 1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                NewsEntities db = new NewsEntities();

                News.tb_User obj = new News.tb_User();
                obj.TenUser  = txtTenNV.Text;
                obj.NickName = txtNgheDanh.Text;
                obj.DiaChi   = txtDiaChi.Text;
                obj.Email    = txtEmail.Text;
                obj.GioiTinh = txtGioiTinh.Text;
                obj.Password = mahoa(txtMaNV.Text);
                db.tb_User.Add(obj);
                db.SaveChanges();

                News.tb_Role objcm = new News.tb_Role();
                objcm.ID_User      = int.Parse(txtMaNV.Text);
                objcm.ID_ChuyenMuc = int.Parse(cbbChuyenMuc.SelectedValue);
                objcm.ID_LoaiTK    = int.Parse(cbbLoaiTK.SelectedValue);

                db.tb_Role.Add(objcm);
                db.SaveChanges();

                Response.Redirect("User.aspx");
            }
            catch
            {
                //
            }
        }
Esempio n. 2
0
        protected void btnAddcm_Click(object sender, EventArgs e)
        {
            NewsEntities db = new NewsEntities();

            News.tb_Role obj1 = new News.tb_Role();

            int cm = int.Parse(cbbChuyenMuc.SelectedValue);

            int tk = int.Parse(cbbLoaiTK.SelectedValue);

            if (int.Parse(cbbLoaiTK.SelectedValue) == 2)
            {
                int count = db.tb_Role.Count(x => x.ID_ChuyenMuc == cm && x.ID_LoaiTK == 2);

                if (count >= 1)
                {
                    lbhienthi1.Text = "Đã có tổng biên cho chuyên mục rồi";
                    return;
                }
            }
            lbhienthi1.Text   = "";
            obj1.ID_User      = Int32.Parse(txtMaNV.Text);
            obj1.ID_LoaiTK    = int.Parse(cbbLoaiTK.SelectedValue);
            obj1.ID_ChuyenMuc = int.Parse(cbbChuyenMuc.SelectedValue);

            db.tb_Role.Add(obj1);
            db.SaveChanges();
            getDGVCM2();
            getDGVCM1();
        }
Esempio n. 3
0
        int gettest()
        {
            NewsEntities db = new NewsEntities();

            News.tb_Role obj1 = new News.tb_Role();
            int          cm   = int.Parse(cbbLoaiTK.SelectedValue);

            int count = db.tb_Role.Count(x => x.ID_ChuyenMuc == cm && x.ID_LoaiTK == 2);

            return(count);
        }
Esempio n. 4
0
        protected void btnThemCM_Click(object sender, EventArgs e)
        {
            NewsEntities db = new NewsEntities();

            News.tb_Role objcm = new News.tb_Role();
            objcm.ID_User      = int.Parse(txtMaNV.Text);
            objcm.ID_ChuyenMuc = int.Parse(cbbChuyenMuc.SelectedValue);
            objcm.ID_LoaiTK    = int.Parse(cbbLoaiTK.SelectedValue);

            db.tb_Role.Add(objcm);
            db.SaveChanges();
        }
Esempio n. 5
0
        protected void btnXoaDGV_Command(object sender, CommandEventArgs e)
        {
            int id   = int.Parse(txtMaNV.Text);
            int idcm = int.Parse(e.CommandArgument.ToString());

            NewsEntities db = new NewsEntities();

            News.tb_Role objcm = db.tb_Role.FirstOrDefault(x => x.ID_User == id && x.ID_ChuyenMuc == idcm);
            if (objcm != null)
            {
                db.tb_Role.Remove(objcm);
                db.SaveChanges();

                getDGVCM();
                getDGVCM1();
                getDGVCM2();
            }
        }