protected void btnsave_Click(object sender, EventArgs e) { Categary obj = new Categary(); obj.CategaryId = Convert.ToInt32(hdnid.Value); obj.CategaryName = txtcname.Text; obj.Description = txtdesc.Text; obj.ParentId = ddlpcat.SelectedItem.Value; obj.PCatName = ddlpcat.SelectedItem.Text; obj.requestedby = Session["uid"].ToString(); int ret = -1; if (hdnid.Value.Equals("0")) { ret = objcat.InsertCategary(obj); } else { ret = objcat.UpdateCategary(obj); } if (ret > 0) { lblmsg.Text = hdnid.Value.Equals("0") ? "Data Save Successfully" : "Data Updated Successfully"; lblmsg.ForeColor = System.Drawing.Color.Green; lblmsg.Font.Bold = true; reset(); } else { lblmsg.Text = "Data Saving Failed"; lblmsg.ForeColor = System.Drawing.Color.Red; lblmsg.Font.Bold = true; } }
public Categary CategoryById(int id) { Categary obj = new Categary(); obj.CategaryId = id; DataTable dt = new DataTable(); dt = objblcategary.GetCategoryDetailByID(obj); Categary retobj = new Categary(); if (dt != null) { if (dt.Rows.Count > 0) { retobj.CategaryId = Convert.ToInt32(dt.Rows[0]["CategaryId"].ToString()); retobj.CategaryName = dt.Rows[0]["CategaryName"].ToString(); retobj.Description = dt.Rows[0]["Description"].ToString(); retobj.InsertedBy = dt.Rows[0]["InsertedBy"].ToString(); retobj.InsertedOn = Convert.ToDateTime(dt.Rows[0]["InsertedOn"].ToString()); retobj.ParentId = dt.Rows[0]["ParentId"].ToString(); retobj.PCatName = dt.Rows[0]["ParentCategory"].ToString(); retobj.UpdatedBy = dt.Rows[0]["UpdatedBy"].ToString(); retobj.UpdatedOn = Convert.ToDateTime(dt.Rows[0]["UpdatedOn"].ToString()); } } return(retobj); }
public int DeleteCategary(int id) { Categary obj = new Categary(); obj.CategaryId = id; return(objblcategary.DeleteCategory(obj)); }
public List <Categary> SubCategoryList(int CategoryId) { DataTable dt = new DataTable(); Categary obj = new Categary(); obj.CategaryId = CategoryId; dt = objblcategary.GetSubCategoryList(obj); List <Categary> lstcat = new List <Categary>(); Categary retobj; if (dt != null) { if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { retobj = new Categary(); retobj.CategaryId = Convert.ToInt32(dt.Rows[i]["CategaryId"].ToString()); retobj.CategaryName = dt.Rows[i]["CategaryName"].ToString(); retobj.Description = dt.Rows[i]["Description"].ToString(); retobj.InsertedBy = dt.Rows[i]["InsertedBy"].ToString(); retobj.InsertedOn = Convert.ToDateTime(dt.Rows[i]["InsertedOn"].ToString()); retobj.ParentId = dt.Rows[i]["ParentId"].ToString(); retobj.PCatName = dt.Rows[i]["ParentCategory"].ToString(); retobj.UpdatedBy = dt.Rows[i]["UpdatedBy"].ToString(); retobj.UpdatedOn = Convert.ToDateTime(dt.Rows[i]["UpdatedOn"].ToString()); lstcat.Add(retobj); } } } return(lstcat); }
public int UpdateCategory(Categary obj) { try { cmd = new SqlCommand(); cmd.CommandText = "SP_MANAGE_CATEGORY"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@action", "UPDATE"); cmd.Parameters.AddWithValue("@categoryid", obj.CategaryId); cmd.Parameters.AddWithValue("@categoryname", obj.CategaryName); cmd.Parameters.AddWithValue("@description", obj.Description); cmd.Parameters.AddWithValue("@parentid", obj.ParentId); cmd.Parameters.AddWithValue("@requestedby", obj.requestedby); return(dbc.ExecuteQuery(cmd)); } catch (Exception ex) { return(-1); } finally { cmd.Dispose(); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Status")] Categary categary) { if (id != categary.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(categary); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategaryExists(categary.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(categary)); }
public async Task <IActionResult> Create([Bind("Id,Name,Status")] Categary categary) { if (ModelState.IsValid) { _context.Add(categary); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(categary)); }
public void getdata(int id) { Categary obj = objcat.CategoryById(id); if (obj != null) { txtcname.Text = obj.CategaryName; txtdesc.Text = obj.Description; hdnid.Value = obj.CategaryId.ToString(); dvgrid.Visible = false; ddlpcat.SelectedValue = obj.ParentId; btnsave.Text = "Update"; } }
public DataTable GetSubCategoryList(Categary obj) { try { cmd = new SqlCommand(); cmd.CommandText = "SP_MANAGE_CATEGORY"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@action", "SubList"); cmd.Parameters.AddWithValue("@categoryid", obj.CategaryId); return(dbc.ExecuteQueryDataTable(cmd)); } catch (Exception ex) { return(null); } finally { cmd.Dispose(); } }
public int DeleteCategory(Categary obj) { try { cmd = new SqlCommand(); cmd.CommandText = "SP_MANAGE_CATEGORY"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@action", "DELETE"); cmd.Parameters.AddWithValue("@categoryid", obj.CategaryId); return(dbc.ExecuteQuery(cmd)); } catch (Exception ex) { return(-1); } finally { cmd.Dispose(); } }
public int UpdateCategary(Categary obj) { return(objblcategary.UpdateCategory(obj)); }
public int InsertCategary(Categary obj) { return(objblcategary.InsertCategory(obj)); }