public void DeleteCategory1(int _id) { //验证是否登陆 IsLogin(); //是否获取到要操作的类别编号 if (_id != 0) { int count = DTO_Category.DeleteCategory(_id); if (count > 0) { //返回类别删除成功 Response.Write(JsonConvert.SerializeObject(new DTO_Result() { Result_Code = "000000", Result_Title = "删除成功" })); } else { //返回自定义类别删除失败 Response.Write(JsonConvert.SerializeObject(new DTO_Result() { Result_Code = new Random().Next(100000, 999999).ToString(), Result_Title = "删除失败" })); } } }
// Update Category public bool updateCategory(DTO_Category category) { try { _conn.Open(); string sql = updateCommon("LOAISACH", "MALOAI", category.category, category.note, category.categoryId); SqlCommand cmd = new SqlCommand(sql, _conn); int rowNumber = cmd.ExecuteNonQuery(); if (rowNumber > 0) { return(true); } } catch (Exception e) { throw e; } finally { _conn.Close(); } return(false); }
/// <summary> /// 名称:添加个人类别视图 /// 时间:18-1-19 /// 作者:赵文涵 /// </summary> /// <returns></returns> public ActionResult AddCategory() { //严重登陆信息 IsLogin(); //int rows; ////如果为""就赋值为1 //if (Request["num"] == "") //{ // rows = 1; //} ////如果为null就赋值为1 //rows = Convert.ToInt32(Request["num"] ?? "1"); //获取当前登陆用户的session int _loginId = (Session["ULogin"] as ULogin).ULogin_Id; //查询全部 List <Category> lis = DTO_Category.SelectCategory(_loginId).ToList(); ////分页后的条数 //List<Category> lis = lis2.Skip((rows - 1) * 5).Take(5).ToList(); ////得到所有条数 //int allcount = lis2.Count(); ////得到所有页数 //int allpage = allcount / 5; ////判断是否除尽或页数是否为0 //if (allcount % 5 != 0 || allpage == 0) // allpage += 1; return(View(lis)); }
private void btnSave_Click(object sender, EventArgs e) { if (txtName.Text == "") { MessageBox.Show("Vui lòng nhập tên loại!", "Thông báo"); return; } DTO_Category info = new DTO_Category(); info.Name = txtName.Text; if (this.action == "add") { bus.addItem(info); } if (this.action == "edit") { info.Id = Convert.ToInt32(txtId.Text); bus.editItem(info); } foreach (DataGridViewRow row in dataGridView.SelectedRows) { this.index = row.Index; } GUI_Category_Load(sender, e); endableAll(true); groupBox.Enabled = false; dataGridView.CurrentCell = dataGridView.Rows[this.index].Cells[0]; }
/** Edit Category Info */ private void btnUpdate_Click(object sender, EventArgs e) { if (!dgvCategory.CurrentRow.Selected) { MessageBox.Show("Hãy chọn tác giả muốn sửa"); return; } int index = this.dgvCategory.SelectedRows[0].Index; int categoryId = Convert.ToInt32(this.dgvCategory.Rows[index].Cells[2].Value); DTO_Category cateId = new DTO_Category(categoryId, txtCategoryName.Text, txtCategoryNote.Text); if (txtCategoryName.Text != "") { if (busCategory.updateCategory(cateId)) { MessageBox.Show("Sửa thông tin tác giả thành công"); this.ShowCategoryList(); } else { MessageBox.Show("Sửa thông tin tác giả ko thành công"); } } else { MessageBox.Show("Tên tác giả không được để trống!"); } }
public int InsertCategory(DTO_Category category) { if (category.Category_name.Contains("'")) { category.Category_name = checkString(category.Category_name); } return(categoryDAO.Insert(category)); }
public void addItem(DTO_Category info) { string[] value = { info.Name }; dataCategory.Insert(value); }
public void dropItem(DTO_Category info) { string[] value = { info.Id.ToString() }; dataCategory.Delete(value); }
public void editItem(DTO_Category info) { string[] value = { info.Name, info.Id.ToString() }; dataCategory.Update(value); }
private void btnDrop_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có muốn xóa hay không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes) { DTO_Category info = new DTO_Category(); info.Id = Convert.ToInt32(txtId.Text); bus.dropItem(info); GUI_Category_Load(sender, e); } }
public JsonResult SearchCategory(string _val) { IsLogin(); //获取用户登录账号编号 var _ulogin = Session["ULogin"] as ULogin; return(Json(DTO_Category.SelectCategory(_ulogin.ULogin_Id, _val), JsonRequestBehavior.AllowGet)); //SelectCategory }
public void InsertFaqCategory(DTO_Category cat) { try { if (!oModule.Admin && !oModule.ManageCategory) { throw new Exception("No permission"); } service.CreateCategory(cat.Name, UserContext.CurrentCommunityID); View.ShowCatInserted(cat, true); } catch { View.ShowCatInserted(cat, false); } }
public int UpdateCategory(DTO_Category category) { try { if (category.Category_name.Contains("'")) { category.Category_name = checkString(category.Category_name); } return(categoryDAO.Update(category)); } catch (Exception) { return(-1); } }
public void DeleteCategory(DTO_Category category) { try { SqlCommand command = new SqlCommand("pr_DeleteCategory", DAL_DBConnect.connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@Category_Id", System.Data.SqlDbType.Int).Value = Convert.ToInt16(category.Id); command.ExecuteNonQuery(); command.Parameters.Clear(); } catch (Exception e) { MessageBox.Show(e.Message.ToString(), "Notice"); } }
public void InsertCategory(DTO_Category category) { try { SqlCommand command = new SqlCommand("pr_InsertCategory", DAL_DBConnect.connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@Category_Name", System.Data.SqlDbType.NVarChar, 15).Value = category.Name; command.ExecuteNonQuery(); command.Parameters.Clear(); } catch (Exception e) { MessageBox.Show(e.Message.ToString(), "Notice"); } }
public void ModifyCat(DTO_Category cat) { //gestione errori... try { if (!oModule.Admin && !oModule.ManageCategory) { throw new Exception("No permission"); } service.UpdateCategory(cat.ID, cat.Name, UserContext.CurrentCommunityID); View.ShowCatModified(cat, true); } catch { View.ShowCatModified(cat, false); } }
public ActionResult WriteBlogIndex() { ULogin u = new ULogin() { ULogin_Id = 1 }; //Session["ULogin"] as ULogin; //查询所有的后台博客类别 List <Backstage_Category> _bclist = DTO_Backstage_Category.SelectBackstage_Category(); //查询所有自定类别 List <Category> clist = DTO_Category.SelectCategory(u.ULogin_Id); @ViewBag._bclist = _bclist; @ViewBag.clist = clist; return(View()); }
public void UpdateTypeCategory1(int _id, string _ct) { //验证是否登陆 IsLogin(); //获取当前登陆用户的session int _loginId = (Session["ULogin"] as ULogin).ULogin_Id; //是否获取到要操作的类别编号 if (_id != 0) { if (DTO_Category.IsContains(_loginId, _id, _ct)) { int count = DTO_Category.UpdateCategory(new Category() { Category_Id = _id, Category_Type = _ct }); if (count > 0) { //返回类别名称修改成功 Response.Write(JsonConvert.SerializeObject(new DTO_Result() { Result_Code = "000000", Result_Title = "修改成功" })); } else { //返回自定义类别修改失败 Response.Write(JsonConvert.SerializeObject(new DTO_Result() { Result_Code = new Random().Next(100000, 999999).ToString(), Result_Title = "修改失败" })); } } else { Response.Write(JsonConvert.SerializeObject(new DTO_Result() { Result_Code = new Random().Next(100000, 999999).ToString(), Result_Title = "\"" + _ct + "\"已存在,修改失败" })); } } }
private void btnInsert_Click(object sender, EventArgs e) { bool valid = true; valid = CustomValidate.Instance.Required(txtName, lblName) == false ? false : valid; if (valid) { DTO_Category category = new DTO_Category(txtName.Text.Trim()); busCategory.InsertCategory(category); clear(); loadCategory(); } else { MessageBox.Show("Vui lòng điền thông tin", "Thông báo"); txtName.Focus(); } }
/// <summary> /// 验证类别下是否存在内容 /// </summary> /// <param name="_id">类别编号</param> /// <returns>查询后的结果集</returns> public JsonResult IsContainChild(string _id) { int _bo = DTO_Category.SelectChildCount(_id); if (_bo > 0) { return(Json(new DTO_Result() { Result_Code = new Random().Next(100000, 999999).ToString(), Result_Title = "该类别下存在内容,是否删除?" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new DTO_Result() { Result_Code = "000000", Result_Title = "" }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 名称:添加个人类别 /// 时间:18-1-19 /// 作者: /// </summary> /// <param name="_ct"></param> public void AddCategory1(string _ct) { IsLogin(); //获取当前登陆用户的session int _loginId = (Session["ULogin"] as ULogin).ULogin_Id; if (DTO_Category.IsContains(_loginId, _ct)) { //创建要添加的数据 Category _ca = new Category() { Category_Type = _ct, Category_Reception = 0, ULogin_Id = _loginId }; int _saveval = DTO_Category.AddCategory(_ca); if (_saveval > 0) { //返回类别添加成功,返回码000000 Response.Write(JsonConvert.SerializeObject(new DTO_Result() { Result_Code = "000000", Result_Title = "添加成功", value = _saveval.ToString() })); } else { //返回类别添加失败 Response.Write(JsonConvert.SerializeObject(new DTO_Result() { Result_Code = new Random().Next(100000, 999999).ToString(), Result_Title = "添加失败" })); } } else { //返回类别已存在提示 Response.Write(JsonConvert.SerializeObject(new DTO_Result() { Result_Code = new Random().Next(100000, 999999).ToString(), Result_Title = "‘" + _ct + "’已存在" })); } }
private void btnAdd_Click(object sender, EventArgs e) { if (checkNull()) { DTO_Category b = new DTO_Category(); b.Category_id = int.Parse(txtID.Text); b.Category_name = txtName.Text; if (bus_category.InsertCategory(b) == 1) { MessageBox.Show("Thành công"); frmCategory_Load(sender, e); reset(); } else MessageBox.Show("Không thành công"); } else { MessageBox.Show("Hãy nhập đủ thông tin"); } }
private void btnDelete_Click(object sender, EventArgs e) { bool valid = true; valid = CustomValidate.Instance.IsInteger(txtId, lblId) == false ? false : valid; if (valid) { if (MessageBox.Show("Bạn có chắc muốn xóa không", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK) { DTO_Category category = new DTO_Category(int.Parse(txtId.Text.Trim())); busCategory.DeleteCategory(category); loadCategory(); clear(); } } else { MessageBox.Show("Vui lòng điền thông tin", "Thông báo"); txtId.Focus(); } }
/** Insert catelogy */ private void btnInsert_Click(object sender, EventArgs e) { if (txtCategoryName.Text == "") { MessageBox.Show("Xin hãy nhập đầy đủ"); return; } DTO_Category dtoCategory = new DTO_Category(6, txtCategoryName.Text, txtCategoryNote.Text); bool insertSuccess = busCategory.insertCategory(dtoCategory); if (insertSuccess == false) { MessageBox.Show("Thêm tác giả thất bại"); return; } MessageBox.Show("Thêm tác giả thành công"); this.ShowCategoryList(); }
public ActionResult UpdateWriteBlogIndex(int Write_blog_Id) { ULogin u = Session["ULogin"] as ULogin;//Session["ULogin"] as ULogin; MonkeyDBEntities db = new MonkeyDBEntities(); //查询所有的后台博客类别 List <Backstage_Category> _bclist = DTO_Backstage_Category.SelectBackstage_Category(); //查询所有自定类别 List <Category> clist = DTO_Category.SelectCategory(u.ULogin_Id); Write_blog wb = db.Write_blog.Where(a => a.Write_blog_Id == Write_blog_Id).FirstOrDefault(); string[] strlist = wb.Category_Id.Split(',');//这篇文章的类型数组 @ViewBag._bclist = _bclist; @ViewBag.clist = clist; @ViewBag.wb = wb; @ViewBag.Mycalist = strlist; return(View()); }
private void btnSeach_Click(object sender, EventArgs e) { if (txtID.Text != "") { DTO_Category dTO_Category = new DTO_Category(); String id = txtID.Text; dTO_Category = bus_category.SearchCategory("category_id", txtID.Text); if (dTO_Category != null) { txtName.Text = dTO_Category.Category_name; } else { MessageBox.Show("Không tìm thấy!"); } } else { MessageBox.Show("Hãy nhập mã sách cần tìm!"); } }
private void btnEdit_Click(object sender, EventArgs e) { if (checkNull()) { DTO_Category b = new DTO_Category(); b.Category_id = int.Parse(id); b.Category_name = txtName.Text; if (bus_category.UpdateCategory(b) == 1) { MessageBox.Show("Thành công"); frmCategory_Load(sender, e); reset(); } else MessageBox.Show("Không thành công"); } else { MessageBox.Show("Hãy điển đủ thông tin!"); } }
public bool insertCategory(DTO_Category category) { return(daoCategory.insertCategory(category)); }
public bool updateCategory(DTO_Category category) { return(daoCategory.updateCategory(category)); }
public int Update(DTO_Category category) { string sql = "UPDATE Category SET category_name = N'" + category.Category_name + "' WHERE category_id = '" + category.Category_id + "';"; return(this.ExecuteNonQuery(sql)); }