public ActionResult Edit(CategoryModel Model) { List <GetCatetoryModel> lstcombobox = new List <GetCatetoryModel>(); _categoryBLL.GetCategory(true, out lstcombobox); ViewBag.Category = lstcombobox; if (ModelState.IsValid) { List <string> lstMsg = new List <string>(); int returnCode = _categoryBLL.Update(Model, out lstMsg); if (!((int)Common.ReturnCode.Succeed == returnCode)) { if (lstMsg != null) { for (int i = 0; i < lstMsg.Count(); i++) { ModelState.AddModelError(string.Empty, lstMsg[i]); } } return(View(Model)); } TempData["Success"] = "Updated Successfully!"; return(RedirectToAction("View", new { @id = Model.id })); } return(View(Model)); }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtCategoryName.Text)) { MessageBox.Show("Category name is emtpy"); } else { if (!isUpdate) { var category = new CategoryDetailDTO(); category.CategoryName = txtCategoryName.Text.Trim(); if (bll.Insert(category)) { MessageBox.Show("Category is added"); txtCategoryName.Clear(); } } else if (isUpdate) { detail.CategoryName = txtCategoryName.Text; if (bll.Update(detail)) { MessageBox.Show("Updated"); this.Close(); } } } }
private void btnUpdate_Click_1(object sender, RoutedEventArgs e) { if (Validate() == false) { return; } if (CategoryBLL.GetDuplicateName(txtboxName.Text, this._category.Id) != null) { MessageBox.Show("Categoryname is already used"); } else { walangforeverRestaurant.Domain.Model.Category category = new walangforeverRestaurant.Domain.Model.Category(); category.Id = Guid.NewGuid(); category.Name = txtboxName.Text; category.Id = this._category.Id; CategoryBLL.Update(category); MessageBox.Show("User successfully Updated."); this._sender.showList(); this.Close(); } }
protected void btnSave_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["catId"]); CategoryBLL cb = new CategoryBLL(); if (Request.QueryString["catId"] == null) { Category c = new Category(); c.Name = txtName.Text; c.IsActive = true; c.Date = DateTime.Now; cb.Add(c); } else { Category c = cb.Get(x => x.Id == id).FirstOrDefault(); c.Name = txtName.Text; c.IsActive = true; c.Date = DateTime.Now; cb.Update(c); } Response.Redirect("Categories.aspx"); }
public async Task <IActionResult> Edit([FromServices] CategoryBLL service, Category model) { if (ModelState.IsValid) { return(Json(await service.Update(model))); } return(MyJsonResultParamInvalid()); }
protected void CategoryDisplayGrid_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName.Equals("Add")) { CategoryBLL categoryManager = new CategoryBLL(); TextBox txtname = (TextBox)CategoryDisplayGrid.FooterRow.FindControl("txtAddname"); // TextBox txtDepId = (TextBox)CategoryDisplayGrid.FooterRow.FindControl("txtAddDepID"); string depName = (CategoryDisplayGrid.FooterRow.FindControl("ddlAddDepName") as DropDownList).SelectedItem.Value; Category categoryToAdd = new Category(); categoryToAdd.Name = txtname.Text; int res; if (int.TryParse(depName, out res)) { categoryToAdd.DepartmentID = res; categoryManager.Add(categoryToAdd); } else { WebMessageBoxUtil.Show("Invalid input in Department field "); } } else if (e.CommandName.Equals("UpdateCategory")) { CategoryBLL categoryManager = new CategoryBLL(); Label id = (Label)CategoryDisplayGrid.Rows[CategoryDisplayGrid.EditIndex].FindControl("lblCat_ID"); TextBox name = (TextBox)CategoryDisplayGrid.Rows[CategoryDisplayGrid.EditIndex].FindControl("txtname"); DropDownList ddlDep = (DropDownList)(CategoryDisplayGrid.Rows[CategoryDisplayGrid.EditIndex].FindControl("ddlDepName")); string depName = ddlDep.SelectedItem.Value; // TextBox departmentId = (TextBox)CategoryDisplayGrid.Rows[e.RowIndex].FindControl("txtDepID"); int selectedId = int.Parse(id.Text); Category categoryToUpdate = new Category();//= empid.Text; categoryToUpdate.CategoryID = selectedId; categoryToUpdate.Name = name.Text; int res; if (int.TryParse(depName, out res)) { categoryToUpdate.DepartmentID = int.Parse(depName); categoryManager.Update(categoryToUpdate); } else { WebMessageBoxUtil.Show("Invalid input in Department field "); } } } catch (Exception exp) { } finally { CategoryDisplayGrid.EditIndex = -1; BindGrid(false); } }
protected void gridViewCategory_RowUpdating(object sender, GridViewUpdateEventArgs e) { categoryDTO.Id = Convert.ToInt32(gridViewCategory.DataKeys[e.RowIndex].Value.ToString()); categoryDTO.Name = e.NewValues[0].ToString(); categoryDTO.Description = e.NewValues[1].ToString(); categoryBLL.Update(categoryDTO); gridViewCategory.EditIndex = -1; ShowGridViewCategory(); }
protected void rptCategories_ItemCommand(object source, RepeaterCommandEventArgs e) { int categoryId = Convert.ToInt32(e.CommandArgument); CategoryBLL cb = new CategoryBLL(); Category c = cb.Get(x => x.Id == categoryId).FirstOrDefault(); c.IsActive = false; cb.Update(c); Fill(); }
protected void ibtnAdd_Click(object sender, EventArgs e) { //验证代码 try { var model = bll.GetModel(int.Parse(hdfID.Value)); model.description = txtContent.Value; model.otherDes1 = txtContent1.Value; model.otherDes2 = txtContent2.Value; bll.Update(model); Msg.Show("保存成功!"); } catch (Exception ex) { log.Error(ex.Message); Msg.Show("网络错误!原因:" + ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { string name = dgvCategory.Rows[RowIndex].Cells[1].Value.ToString(); if (!name.Equals(txtName.Text)) { if (string.IsNullOrWhiteSpace(txtName.Text)) { MessageBox.Show("Please enter a name"); return; } CategoryBLL categoryBLL = new CategoryBLL(); if (categoryBLL.Update(txtID.Text, txtName.Text)) { MessageBox.Show("Sucess"); } } // end LoadData(); txtID.ReadOnly = true; }
private void btnSave_Click(object sender, EventArgs e) { _cat.CategoryName = txtName.Text; _cat.Description = txtDesc.Text; bool result; if (isSave == true) { result = _categoryBLL.Insert(_cat); } else { result = _categoryBLL.Update(_cat); } if (result) { MessageBox.Show("İşlem başarıyla gerçekleşti."); } else { MessageBox.Show("İşlem sırasında bir hata oluştu."); } }
protected void btnSave_Click(object sender, EventArgs e) { model.CategoryName = KillSqlIn.Form_ReplaceByString(Request.Form["txtTitle"], 200); model.Sort = Convert.ToInt32(KillSqlIn.Form_ReplaceByNumber(Request.Form["txtSort"], 4)); model.AddedUserId = Convert.ToInt32(_userId); model.AddedDate = Convert.ToDateTime(this.txtAddDate.Text); model.ParentCategoryId = Convert.ToInt32(this.ddlParentCategory.SelectedValue); model.Type = 0;//0:文章 1:新闻 //string BackUrl = "CategoryTree.aspx"; if (_ACid != "0") { model.CategoryId = Convert.ToInt32(_ACid); bll.Update(model); ClientScript.RegisterStartupScript(this.GetType(), "js", "<script>alert('修改成功!');layer_close_refresh();</script>"); //JSUtility.AlertAndRedirect("修改成功!", BackUrl); /*日志归档*/ //string sql1 = @"select Title as title from dbo.T_Category where CategoryId = (" + _ACid + ")"; //string function = "修改"; //PubFunction.InsertLog1("文章类别管理", sql1, function); } else { model.AddedDate = DateTime.Now; int id = bll.Add(model); bll.UpdateCategoryPermission(id.ToString()); JSUtility.AlertAndRedirect("添加成功,请继续添加!", Request.RawUrl.ToString()); /*日志归档*/ //string sql1 = @"select Title as title from dbo.T_Category where CategoryId = (select top 1 CategoryId from T_Category order by CategoryId desc)"; //string function = "添加"; //PubFunction.InsertLog1("文章类别管理", sql1, function); } }
private void btnSave_Click(object sender, EventArgs e) { if (txtCategoryNamw.Text.Trim() == "") { MessageBox.Show("Category is empty"); } else { if (!isUpdate) { CategoryDetailDTO category = new CategoryDetailDTO(); category.CategoryName = txtCategoryNamw.Text; if (bll.Insert(category)) { MessageBox.Show("Category was added"); txtCategoryNamw.Clear(); } } else { if (detail.CategoryName == txtCategoryNamw.Text.Trim()) { MessageBox.Show("Thre is not change"); } else { detail.CategoryName = txtCategoryNamw.Text; if (bll.Update(detail)) { MessageBox.Show("Category was updated"); this.Close(); } } } } }
public void Update(Category category) { service.Update(category); }
private void btnSave_Click(object sender, EventArgs e) //存盘按钮事件 { if (op == Operation.INSERT) //新增按钮被点击 { //判断是否输入了所有的值 if (txtCategoryID.Text == "" || txtCategoryName.Text == "") { MessageBox.Show("请输入所有的值", "提示"); } //获取文本框的值给对象的属性赋值 cate = new Category(); cate.CategoryID = txtCategoryID.Text.Trim(); cate.CategoryName = txtCategoryName.Text.Trim(); try { //判断执行是否成功(新增) if (categoryBll.Insert(cate)) { MessageBox.Show("新增成功!", "提示"); txtCategoryID.Text = string.Empty; //清空文本框的值(效率比clear高) txtCategoryName.Text = string.Empty; //清空文本框的值(效率比clear高) BindDateGridView(); //调用填充方法 重新填充DateGridView的数据(刷新结果) dgCategroy.CurrentRow.Selected = false; //取消行的选中状态(第一行) for (int i = 0; i < list.Count; i++) //新增的当前行被选中 { if (list[i].CategoryID == cate.CategoryID) { dgCategroy.Rows[i].Selected = true; //自动跳转到查找到的行 dgCategroy.FirstDisplayedScrollingRowIndex = i; break; } } } else { MessageBox.Show("新增失败!", "提示"); return; } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } else if (op == Operation.UPDATE) //修改按钮被点击 { if (cate == null) { MessageBox.Show("请选择要修改的数据!", "提示"); return; } cate.CategoryName = txtCategoryName.Text.Trim(); //获取文本框的值给对象的属性赋值 try { //判断执行是否成功(更新) if (categoryBll.Update(cate)) { MessageBox.Show("更新成功!", "提示"); BindDateGridView(); //重新填充ateGridView (刷新结果) dgCategroy.CurrentRow.Selected = false; //取消行的选中状态(第一行) dgCategroy.Rows[currentRowsIndex].Selected = true; //将当前被更新的行进行反蓝色显示 //自动跳转到查找到的行 dgCategroy.FirstDisplayedScrollingRowIndex = currentRowsIndex; } else { MessageBox.Show("更新失败!", "提示"); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } else if (op == Operation.DELETE) //删除按钮被点击 { if (cate == null) { MessageBox.Show("请选择要删除的数据!", "提示"); } //弹出是否确认删除的对话框 DialogResult result = MessageBox.Show("您是否真的要删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { try { if (categoryBll.Delete(cate)) { MessageBox.Show("删除成功", "提示"); BindDateGridView(); dgCategroy.CurrentRow.Selected = false; //取消行的选中状态(第一行) cate = null; //清空参数 //直接初始化 当前窗口 btnNewAdd.Enabled = btnModify.Enabled = btnDelete.Enabled = true; gbInfo.Visible = false; } else { MessageBox.Show("删除失败!", "提示"); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } } }
protected void ibtnAdd_Click(object sender, EventArgs e) { //验证代码 try { if (string.IsNullOrEmpty(Request.QueryString["type"] + "")) { Category model = new Category(); model.codeNo = txtCode.Text.Trim().Replace(" ", ""); model.id = int.Parse(hdfnodeID.Value); model.parentID = int.Parse(hdfparentID.Value); model.title = txtTitle.Text; model.orderId = int.Parse(hdforderID.Value); model.description = hdfDes.Value; model.stateID = ddlState.SelectedIndex; model.imgPath = hdfImg.Value; model.typeID = int.Parse(rbtType.SelectedItem.Value + ""); model.outLink = txtLink.Text; bll.Update(model); Response.Redirect("Default.aspx?id=" + model.id, false); } else { if (!string.IsNullOrEmpty(Request.QueryString["type"] + "")) { Category model = new Category(); model.title = txtTitle.Text; model.codeNo = txtCode.Text; // 防止网页重复提交 if (!bll.ExistsCode(model.codeNo)) { try { model.parentID = int.Parse(Request.QueryString["pid"]); } catch { Msg.Show("参数错误!"); } model.orderId = bll.GetChildNum(model.parentID); model.description = ""; model.stateID = ddlState.SelectedIndex; model.typeID = rbtType.SelectedIndex; model.outLink = txtLink.Text; // model.imgPath = int res = bll.Add(model); Response.Redirect("Default.aspx?id=" + res, false); } else { Msg.Show("编码已存在!"); } } } } catch (Exception ex) { log.Error(ex.Message); Msg.Show("网络错误!原因:" + ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (op == Operation.Insert) { foreach (Control con in gbInfo.Controls) { if (con is TextBox && con.Text == "") { MessageBox.Show("请输入所有值!"); con.Focus(); return; } } c = new Category(); c.CategoryID = txtCategoryID.Text.Trim(); c.CategoryName = txtCategoryName.Text.Trim(); if (cBLL.Insert(c)) { MessageBox.Show("新增成功!"); BindDate(); for (int i = 0; i < list.Count; i++) { if (list[i].CategoryID == c.CategoryID) { dgCategoryInfo.Rows[i].Selected = true; break; } } } else { MessageBox.Show("新增失败!"); } } else if (op == Operation.Update) { if (c == null) { MessageBox.Show("请选择要修改的记录!"); return; } c.CategoryName = txtCategoryName.Text.Trim(); if (cBLL.Update(c)) { MessageBox.Show("修改成功!"); BindDate(); dgCategoryInfo.Rows[currentIndex].Selected = true; } else { MessageBox.Show("修改失败!"); } } else if (op == Operation.Delete) { if (c == null) { MessageBox.Show("请选择要删除的记录!"); return; } if (cBLL.Delete(c)) { MessageBox.Show("删除成功!"); BindDate(); c = null; } else { MessageBox.Show("删除失败!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }