private void button2_Click(object sender, EventArgs e)
        {
            var fullname = textBoxFullname.Text;

            if (fullname == "")
            {
                MessageBox.Show("Hãy nhập họ tên để thêm !");
            }
            else
            {
                TacGia tg = new TacGia()
                {
                    HoTenTG   = textBoxFullname.Text,
                    DiaChi    = textBoxAddress.Text,
                    TieuSu    = textBoxBackground.Text,
                    DienThoai = textBoxPhone.Text,
                };
                TacGiaDao tgDao = new TacGiaDao();
                var       res   = tgDao.insertAuthor(tg.HoTenTG, tg.DiaChi, tg.TieuSu, tg.DienThoai);
                if (res > 0)
                {
                    MessageBox.Show("Thêm tác giả thành công !");
                }
                bindDataToGrid();
                clearAll();
            }
        }
示例#2
0
        public ActionResult Edit(TacGia item)
        {
            if (ModelState.IsValid)
            {
                if (item.TacGiaID == -1)
                {
                    // add more fields not in database
                    item.UserModified = item.UserCreated = User.Username;
                    item.DateModified = item.DateCreated = DateTime.UtcNow;


                    TacGiaManager.Instance.CreateItem(item);
                }
                else
                {
                    var existingItem = TacGiaManager.Instance.GetItem(item.TacGiaID);

                    existingItem.ButDanh      = item.ButDanh;
                    existingItem.Ten          = item.Ten;
                    existingItem.DiaChi       = item.DiaChi;
                    existingItem.Email        = item.Email;
                    existingItem.Phone        = item.Phone;
                    existingItem.UserModified = User.Username;
                    existingItem.DateModified = DateTime.UtcNow;

                    TacGiaManager.Instance.UpdateItem(existingItem);
                }

                return(RedirectToDefaultRoute());
            }
            else
            {
                return(View(item));
            }
        }
示例#3
0
        public int Update(int id, string tenTacGia, string moTa, int trangThai)
        {
            var author = db.TacGia.Find(id);

            if (author.TenTacGia.Trim().ToUpper() == tenTacGia.Trim().ToUpper())
            {
                author.MoTa      = moTa;
                author.TrangThai = trangThai;
                db.SaveChanges();
                return(1);
            }
            else
            {
                TacGia auth = db.TacGia.Where(c => c.TenTacGia.Trim().ToUpper() == tenTacGia.Trim().ToUpper() && c.Id != id).FirstOrDefault();
                if (auth != null)
                {
                    return(0);
                }
                else
                {
                    author.TenTacGia = tenTacGia;
                    author.MoTa      = moTa;
                    author.TrangThai = trangThai;
                    db.SaveChanges();
                    return(1);
                }
            }
        }
示例#4
0
 public ActionResult Add(TacGia tacgia)
 {
     if (Session["User"] == null)
     {
         return(RedirectToAction("Login", "Login"));
     }
     else
     {
         var model = new TacGiaDao().CheckTacGia(tacgia.TenTacGia, tacgia.Email);
         if (model == false)
         {
             ModelState.AddModelError("", "Tác Giả Này Đã Tồn Tại");
             return(View("Add"));
         }
         else
         {
             if (ModelState.IsValid)
             {
                 var dao = new TacGiaDao();
                 int id  = dao.Insert(tacgia);
                 if (id > 0)
                 {
                     return(RedirectToAction("Index", "TacGiaAD"));
                 }
                 else
                 {
                     ModelState.AddModelError("", "Thêm Mới Thất Bại");
                     return(View("Add"));
                 }
             }
         }
         return(View("Index"));
     }
 }
示例#5
0
 public ActionResult Edit(TacGia tacgia)
 {
     if (Session["User"] == null)
     {
         return(RedirectToAction("Login", "Login"));
     }
     else
     {
         var model = new TacGiaDao().CheckTacGia(tacgia.TenTacGia, tacgia.Email);
         if (model == false)
         {
             ModelState.AddModelError("", "Tác Giả Này Đã Tồn Tại");
             return(View("Edit"));
         }
         else
         {
             if (ModelState.IsValid)
             {
                 var dao    = new TacGiaDao();
                 var result = dao.Update(tacgia);
                 if (result)
                 {
                     return(RedirectToAction("Index", "TacGiaAD"));
                 }
                 else
                 {
                     ModelState.AddModelError("", "Cập Nhật Khách Hàng  Thất Bại");
                     return(View("Edit"));
                 }
             }
             return(View("Index"));
         }
     }
 }
示例#6
0
        public ActionResult ChinhSuaTacGia(int idTacGia)
        {
            string        mainconn = ConfigurationManager.ConnectionStrings["WEBBANSACH"].ConnectionString;
            SqlConnection sqlconn  = new SqlConnection(mainconn);
            SqlCommand    sqlcomm  = new SqlCommand("[dbo].[XemChiTietTacGia]");

            sqlconn.Open();
            sqlcomm.Connection  = sqlconn;
            sqlcomm.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter sd = new SqlDataAdapter(sqlcomm);

            sqlcomm.Parameters.AddWithValue("@MaTacGia", idTacGia);

            DataTable dt = new DataTable();

            sd.Fill(dt);
            sqlconn.Close();
            TacGia xem = new TacGia();

            foreach (DataRow dr in dt.Rows)
            {
                xem.MaTacGia  = Convert.ToInt32(dr["MaTacGia"]);
                xem.TenTacGia = Convert.ToString(dr["TenTacGia"]);
                xem.DiaChi    = Convert.ToString(dr["DiaChi"]);
                xem.TieuSu    = Convert.ToString(dr["TieuSu"]);
                xem.SDT       = Convert.ToString(dr["SDT"]);
            }
            return(View(xem));
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (textBoxAuthorName.Text == "")
            {
                MessageBox.Show("Hãy nhập tên tác giả !");
            }
            else
            {
                var author = new TacGia()
                {
                    HoTenTG   = textBoxAuthorName.Text,
                    DiaChi    = textBoxAuthorAddress.Text,
                    DienThoai = textBoxAuthorPhone.Text,
                    TieuSu    = textBoxAuthorBackground.Text
                };

                TacGiaDao dao = new TacGiaDao();
                var       res = dao.insertAuthor(author.HoTenTG, author.DiaChi, author.TieuSu, author.DienThoai);
                if (res > 0)
                {
                    MessageBox.Show("Thêm thành công !");
                    clearAll();
                }
                else
                {
                    MessageBox.Show("Chưa thêm được !");
                }
            }
        }
示例#8
0
        /// <summary>
        /// Cập nhật thông tin chu kỳ phát hành
        /// Author       :   HoangNM - 16/03/2019 - create
        /// </summary>
        /// <param name="tacGia">thông tin về tác giả muốn thay đổi</param>
        /// <returns>Trả về các thông tin khi cập nhật tác giả, Excetion nếu có lỗi</returns>
        public ResponseInfo UpadateTacGia(TacGia tacGia, int id)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();
            ResponseInfo         response    = new ResponseInfo();

            try
            {
                context.TacGias.Where(x => x.Id == id && !x.DelFlag)
                .Update(x => new TblTacGia
                {
                    TenTacGia = tacGia.TenTacGia,
                });
                context.SaveChanges();
                response.IsSuccess = true;
                transaction.Commit();
                var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.CapNhatDuLieuThanhCong);
                response.TypeMsgError = errorMsg.Type;
                response.MsgError     = errorMsg.Msg;
                return(response);
            }
            catch (Exception e)
            {
                response.IsSuccess = false;
                transaction.Rollback();
                throw e;
            }
        }
示例#9
0
        /// <summary>
        /// Thêm tác giả
        /// Author       :   HoangNM - 16/03/2019 - create
        /// </summary>
        /// <param name="tacGia">tác giả sẽ thêm</param>
        /// <returns>Trả về các thông tin khi thêm tác giả, Excetion nếu có lỗi</returns>
        public ResponseInfo ThemTacGia(TacGia tacGia)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();

            try
            {
                ResponseInfo response = new ResponseInfo();

                int id = context.ChuKyPhatHanhs.Count() == 0 ? 1 : context.ChuKyPhatHanhs.Max(x => x.Id) + 1;
                context.TacGias.Add(new TblTacGia
                {
                    TenTacGia = tacGia.TenTacGia
                });
                context.SaveChanges();
                response.ThongTinBoSung1 = id + "";
                transaction.Commit();
                var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.ThemDuLieuThanhCong);
                response.TypeMsgError = errorMsg.Type;
                response.MsgError     = errorMsg.Msg;
                return(response);
            }
            catch (Exception e)
            {
                transaction.Rollback();
                throw e;
            }
        }
示例#10
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            /*fTacGia_Create f = new fTacGia_Create();
             * this.Hide();
             * f.ShowDialog();
             * this.Show();*/
            string maTacGia, tenTacGia, diaChi, Sdt, Email, GioiTinh, QuocTich;

            maTacGia  = maTGMoi;
            tenTacGia = txtTenTG.Text;
            diaChi    = txtDiaChi.Text;
            Sdt       = txtSDT.Text;
            Email     = txtEmail.Text;
            GioiTinh  = cboGioiTinh.Text;
            QuocTich  = cboQuocTich.Text;

            if (!notEmptyFields()) //neu chua nhap day du thong tin
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin", "Waring", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                TacGia TG = new TacGia(maTacGia, tenTacGia, diaChi, Sdt, Email, GioiTinh, QuocTich);
                if (!handler.themTacGia(TG)) //Neu them khong thanh cong
                {
                    MessageBox.Show("Mã lĩnh vực đã tồn tại: " + maTacGia, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else //Thanh cong
                {
                    MessageBox.Show("Sucessfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    show();          //load lai table
                    txtMaTG.Focus(); //set focus
                }
            }
        }
 protected void grvTacGiaa_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName != "Page")
     {
         GridViewRow gvr;
         gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
         int index = gvr.RowIndex;
         if (e.CommandName == "Sua")
         {
             GridViewRow gvrow = grvTacGia.Rows[index];
             typemodal.Value = "TG";
             editType.Value  = "edit"; //đoạn này
             hdId.Value      = grvTacGia.DataKeys[index].Value.ToString();
             TacGia tg = tgbll.LayTacGia(hdId.Value);
             txtTen.Text  = tg.HoTenTacGia;
             txtMoTa.Text = tg.MoTa;
         }
         else
         if (e.CommandName == "Xoa")
         {
             GridViewRow gvrow = grvTacGia.Rows[index];
             string      id    = HttpUtility.HtmlDecode(gvrow.Cells[0].Text).ToString();
             editType.Value = "edit";
             idDelete.Value = id;
             Delete.Value   = "TG";
             LoadTG();
             tgbll.Xoa(id);
             typemodal.Value = "hide";
             LoadTG();
         }
     }
 }
示例#12
0
        //Xóa tác giả
        public bool XoaAuthor(TacGia tg)
        {
            con1 = con.getConnection();
            try
            {
                con1.Open();
                string SQL = string.Format("DELETE FROM TacGia WHERE MaTG =@MaTG");

                SqlCommand cmd = new SqlCommand(SQL, con1);
                cmd.Parameters.AddWithValue("@MaTG", tg.maTG);
                cmd.Parameters.AddWithValue("@TenTG", tg.tenTG);

                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                con1.Close();
            }

            return(false);
        }
示例#13
0
 //thêm tác giả
 public bool themAuthor(TacGia tg)
 {
     con1 = con.getConnection();
     try
     {
         con1.Open();
         string     SQL = string.Format("insert into TacGia values(@MaTG, @TenTG)");
         SqlCommand cmd = new SqlCommand(SQL, con1);
         cmd.Parameters.AddWithValue("@MaTG", tg.maTG);
         cmd.Parameters.AddWithValue("@TenTG", tg.tenTG);
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception)
     {
     }
     finally
     {
         // Dong ket noi
         con1.Close();
     }
     return(false);
 }
示例#14
0
        public TacGia GetData(String ma)
        {
            TacGia tg = new TacGia();

            cmd.CommandText = String.Format("Select * from TacGia where MaTG = '{0}' ", ma);
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con.Connection;
            try
            {
                con.OpenConn();
                SqlDataReader reader    = cmd.ExecuteReader();
                int           ordMaNV   = reader.GetOrdinal("MaTG");
                int           ordTenNV  = reader.GetOrdinal("TenTG");
                int           ordDiaChi = reader.GetOrdinal("DiaChi");
                int           ordSDT    = reader.GetOrdinal("SDT");
                while (reader.Read())
                {
                    tg.MaTG   = reader.GetString(ordMaNV);
                    tg.TenTG  = reader.GetString(ordTenNV);
                    tg.DiaChi = reader.GetString(ordDiaChi);
                    tg.SDT1   = reader.GetInt32(ordSDT);
                }
                reader.Close();
                con.CloseConn();
            }
            catch (Exception ex)
            {
                string mex = ex.ToString();
                cmd.Dispose();
                con.CloseConn();
            }
            return(tg);
        }
示例#15
0
        public List <TacGia> getTacGia()
        {
            string sql = "SELECT * FROM TacGia";
            string id, name, text;

            List <TacGia> list = new List <TacGia>();

            Connect();

            try
            {
                SqlDataReader dr = myExecuteReader(sql);
                while (dr.Read())
                {
                    id   = dr[0].ToString();
                    name = dr[1].ToString();
                    text = dr[2].ToString();
                    TacGia tg = new TacGia(id, name, text);
                    list.Add(tg);
                }
                dr.Close();
                return(list);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                Disconnect();
            }
        }
示例#16
0
        public IHttpActionResult PutTacGia(string id, TacGia tacGia)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tacGia.IDTacGia)
            {
                return(BadRequest());
            }

            db.Entry(tacGia).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TacGiaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#17
0
        private void dgvTacGia_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                var senderGrid = (DataGridView)sender;

                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
                {
                    string id   = txtIDTacGia.Text;
                    string name = txtTenTG.Text;
                    string text = txtGhiChu.Text;

                    TacGia tg = new TacGia(id, name, text);
                    bool   b  = new TacGiaBUS().DeleteTG(tg);
                    if (b)
                    {
                        MessageBox.Show("Xóa Thành Công");
                    }
                    Init();
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Xóa thất bại", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#18
0
        public IHttpActionResult PostTacGia(TacGia tacGia)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TacGias.Add(tacGia);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (TacGiaExists(tacGia.IDTacGia))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = tacGia.IDTacGia }, tacGia));
        }
示例#19
0
        public ActionResult ChinhSuaTacGia(FormCollection f, int idTacGia, TacGia tacGia)
        {
            string sTenTacGia = f.Get("TenTacGia").ToString();
            string sDiaChi    = f["DiaChi"].ToString();
            string sSDT       = f["SDT"].ToString();
            string sTieuSu    = f["TieuSu"].ToString();

            string        mainconn = ConfigurationManager.ConnectionStrings["WEBBANSACH"].ConnectionString;
            SqlConnection sqlconn  = new SqlConnection(mainconn);
            SqlCommand    sqlcomm  = new SqlCommand("[dbo].[ChinhSuaTacGia]");

            sqlconn.Open();
            sqlcomm.Connection  = sqlconn;
            sqlcomm.CommandType = CommandType.StoredProcedure;
            sqlcomm.Parameters.AddWithValue("@MaTacGia", idTacGia);
            sqlcomm.Parameters.AddWithValue("@TenTacGia", sTenTacGia);
            sqlcomm.Parameters.AddWithValue("@DiaChi", sDiaChi);
            sqlcomm.Parameters.AddWithValue("@TieuSu", sTieuSu);
            sqlcomm.Parameters.AddWithValue("@SDT", sSDT);
            SqlDataReader sdr = sqlcomm.ExecuteReader();



            return(RedirectToAction("XemTacGia", "Admin"));
        }
示例#20
0
        public bool suaTacGia(TacGia TG)
        {
            doc = new XmlDocument(); //Tao moi 1 doi tuong XmlDocument
            doc.Load(fileName);      //Ltoad file xml theo duong dan
            list = new List <TacGia>();

            loadDataFromDoc(doc, fileName, list);
            if (!isExistId(list, TG.MaTacGia))                       //Kiem tra ma co ton tai hay khong
            {
                return(false);                                       //Neu khong tra ve false
            }
            XmlNodeList tgNode = doc.GetElementsByTagName("TacGia"); //Lay danh sach cac nut linh vuc tu tai lieu

            foreach (XmlNode node in tgNode)
            {
                string maTacGia = node.ChildNodes[0].InnerText; //Lay ra MaLinhVuc cua nut LinhVuc hien tai
                if (maTacGia == TG.MaTacGia)                    //Neu MaLinhVuc cua nut hien tai trung voi MaLinhVuc can sua
                {
                    //Thuc hien sua doi thong tin cua nut nay
                    node.ChildNodes[0].InnerText = TG.MaTacGia;
                    node.ChildNodes[1].InnerText = TG.TenTacGia;
                    node.ChildNodes[2].InnerText = TG.DiaChi;
                    node.ChildNodes[3].InnerText = TG.Sdt;
                    node.ChildNodes[4].InnerText = TG.Email;
                    node.ChildNodes[5].InnerText = TG.GioiTinh;
                    node.ChildNodes[6].InnerText = TG.QuocTich;
                    break;
                }
            }

            doc.Save(fileName); // Sau khi sua luu lai file

            return(true);       //tra ve true khi sua thanh cong
        }
示例#21
0
        public ActionResult Add(TacGia tg)
        {
            KhachHang kh = new KhachHang();

            kh = Session["KhachHang"] as KhachHang;
            if (kh == null)
            {
                return(RedirectToAction("Index", "DangNhap"));
            }
            else if (kh.LoaiKH == "Khách Hàng")
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                using (var db = new BookContext())
                {
                    Log log = new Log();
                    log.TacVu    = "Admin";
                    log.TaiKhoan = kh.TaiKhoan;
                    log.ThoiGian = DateTime.Now;
                    log.HanhDong = "Đã thêm tác giả có tên " + tg.TenTacGia;
                    db.Log.Add(log);


                    TacGia tacGia = new TacGia();
                    tacGia.TenTacGia = tg.TenTacGia;
                    db.TacGia.Add(tg);
                    db.SaveChanges();
                    Session["ListTG"] = db.TacGia.Where(i => i.flag == false).ToList();
                    return(RedirectToAction("Index", "TacGia"));
                }
            }
        }
示例#22
0
        public ActionResult Update(TacGia tg)
        {
            KhachHang kh = new KhachHang();

            kh = Session["KhachHang"] as KhachHang;
            if (kh == null)
            {
                return(RedirectToAction("Index", "DangNhap"));
            }
            else if (kh.LoaiKH == "Khách Hàng")
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                TacGia tacGia = db.TacGia.Find((Session["TG"] as TacGia).MaTacGia);
                if (tacGia.TenTacGia != tg.TenTacGia)
                {
                    Log log = new Log();
                    log.TacVu    = "Admin";
                    log.TaiKhoan = kh.TaiKhoan;
                    log.ThoiGian = DateTime.Now;
                    log.HanhDong = "Đã cập nhật tác giả có tên " + tacGia.TenTacGia + " thành " + tg.TenTacGia;
                    db.Log.Add(log);
                }
                tacGia.TenTacGia = tg.TenTacGia;
                db.SaveChanges();
                return(RedirectToAction("Index", "TacGia"));
            }
        }
示例#23
0
        public ActionResult Index(TacGia tg, string moTa, HttpPostedFileBase file)
        {
            var tk = Session["TaiKhoan"] as KhachHang;

            if (tk == null)
            {
                return(View("../Login/Index"));
            }
            else
            {
                if (tk.LoaiTK != "Admin")
                {
                    return(View("../Home/Index"));
                }
                else
                {
                    if (Session["UpdateTG"] == null)
                    {
                        var db = new TacGiaDAO();
                        db.InsertTG(tg, moTa, file);
                        Session["ListTG"] = null;
                        return(RedirectToAction("Reset", "TacGia", new { area = "Admin" }));
                    }
                    else
                    {
                        var db  = new TacGiaDAO();
                        var tg1 = Session["UpdateTG"] as TacGia;
                        db.UpdateTG(tg1.IdTacGia, tg, moTa, file);
                        Session["UpdateTG"] = null;
                        Session["ListTG"]   = null;
                        return(RedirectToAction("Reset", "TacGia", new { area = "Admin" }));
                    }
                }
            }
        }
        public async Task <IActionResult> Edit(int id, TacGia tacGia)
        {
            if (id != tacGia.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _db.Update(tacGia);
                    await _db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TacGiaExists(tacGia.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tacGia));
        }
示例#25
0
 private void cbbMaTG_TextChanged(object sender, EventArgs e)
 {
     using (Model_QuanLi_ThuVien qltv = new Model_QuanLi_ThuVien())
     {
         bool tmt      = false;
         var  ListMaTG = from kq in qltv.TacGias select kq.MaTacGia;
         foreach (var item in ListMaTG)
         {
             if (cbbMaTG.Text == item)
             {
                 tmt = true;
             }
         }
         if (tmt == true)
         {
             TacGia TG    = qltv.TacGias.Where(p => p.MaTacGia == cbbMaTG.Text).SingleOrDefault();
             var    ViTri = from kq in qltv.SangTacs where kq.MaDauSach == QuanLyDauSach.MaDS && kq.MaTacGia == cbbMaTG.Text select kq.ViTriVaiTro;
             txbTenTG.Text          = TG.TenTacGia;
             dTP_NgaySinhTG.Text    = TG.NgaySinh.ToString();
             txbViTriVaiTro.Text    = "";
             dTP_NgaySinhTG.Enabled = false;
             txbTenTG.Enabled       = false;
         }
         else
         {
             txbTenTG.Enabled       = true;
             dTP_NgaySinhTG.Enabled = true;
             txbTenTG.Text          = "";
             txbViTriVaiTro.Text    = "";
             dTP_NgaySinhTG.Value   = DateTime.Now;
         }
     }
 }
示例#26
0
 /// <summary>
 /// thêm thông tin tác giả vào database
 /// </summary>
 public static void AddTacGia(TacGia TacGia)
 {
     using (var db = new LiteDatabase(DatabaseConnectionString))
     {
         db.GetCollection <TacGia>("TacGia").Insert(TacGia);
     }
 }
        public ResponseInfo UpdateTacGia(TacGia data, int id)
        {
            ResponseInfo response = new ResponseInfo();
            var          kt       = Convert.ToInt64(new GetPermission().GetQuyen("AUTHOR_UPD")) & Convert.ToInt64(Common.Common.GetTongQuyen());

            if (kt != 0)
            {
                try
                {
                    response = new QuanLyTacGiaModel().UpadateTacGia(data, id);
                }
                catch (Exception e)
                {
                    response.Code = (int)ConstantsEnum.CodeResponse.ServerError;
                    var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.ServerError);
                    response.TypeMsgError    = errorMsg.Type;
                    response.MsgError        = errorMsg.Msg;
                    response.ThongTinBoSung1 = e.Message;
                }
            }
            else
            {
                var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.BanKhongDuQuyen);
                response.TypeMsgError = errorMsg.Type;
                response.MsgError     = errorMsg.Msg;
            }

            return(response);
        }
示例#28
0
        public ActionResult DeleteConfirmed(int id)
        {
            TacGia tacGia = db.TacGia.Find(id);

            db.TacGia.Remove(tacGia);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#29
0
 public string Insert(TacGia author)
 {
     {
         db.TacGias.Add(author);
         db.SaveChanges();
         return(author.MaTacGia);
     }
 }
 public TacGia LayTGTheoMa(string maTacGia)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         TacGia tacGia = ThuVienDS.TacGias.Find(maTacGia);
         return(tacGia);
     }
 }