/// <summary> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param> private void BindGrid(bool addRow, bool deleteRow) { SubCategoryBLL SubCategoryBLLobj = new SubCategoryBLL(); grdSubcategory.DataSource = SubCategoryBLLobj.GetALLSubCategory(Convert.ToInt32(ViewState["BGT_CATEGORYID"])); grdSubcategory.DataBind(); }
/// <summary> /// Set edit mode for edit comand /// Delete data from the database for delete comand /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdSubCategory_RowCommand(object sender, GridViewCommandEventArgs e) { string message = string.Empty; if (e.CommandName == "EditRow") { ViewState["BGT_SUBCATEGORYID"] = e.CommandArgument; GetSubCategoryDetails(); SetUpdateMode(true); } else if (e.CommandName == "DeleteRow") { SubCategoryBLL SubCategoryBLLobj = new SubCategoryBLL(); message = SubCategoryBLLobj.DeleteSubCategory(Convert.ToInt32(e.CommandArgument)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data deleted successfully"; } ClearAll(); SetUpdateMode(false); BindGrid(false, true); } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } }
/// <summary> /// Update Database Make data as Obsoluted /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void IsObsolete_CheckedChanged(Object sender, EventArgs e) { string message = string.Empty; try { CheckBox chk = (CheckBox)sender; GridViewRow gr = (GridViewRow)chk.Parent.Parent; string BGT_SUBCATEGORYID = ((Literal)gr.FindControl("ltlObsolete")).Text; int BGT_SUBCATEGORYID_ = Convert.ToInt32(BGT_SUBCATEGORYID); SubCategoryBLL SubCategoryBLLobj = new SubCategoryBLL(); message = SubCategoryBLLobj.ObsoleteSubCategory(BGT_SUBCATEGORYID_, Convert.ToString(chk.Checked)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; } BindGrid(false, true); if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } } catch (Exception ex) { throw ex; } }
private void BindGrid(bool addRow, bool deleteRow) { SubCategoryBLL SubCategoryBLLobj = new SubCategoryBLL(); grdSubcategory.DataSource = SubCategoryBLLobj.GetALLSubCategory(); grdSubcategory.DataBind(); }
public static List <SubCategory> GetSubCategories(bool?state = true) { var subcategoryBLL = new SubCategoryBLL(); ListSubCategories = subcategoryBLL.GetSubCategories(state); return(ListSubCategories); }
private void BindDropSearch() { ddlSubCatName.DataSource = SubCategoryBLL.GetAllSubCategories(); ddlSubCatName.Items.Insert(0, new ListItem("Select SubCategory", "")); ddlSubCatName.DataTextField = "subCatName"; ddlSubCatName.DataValueField = "subCatID"; ddlSubCatName.DataBind(); }
public void BinddrpCatogory() { DataSet ds2 = new DataSet(); ds2 = SubCategoryBLL.GetAllSubCategories(); drpcategory.Items.Insert(0, new ListItem("Select Category", "")); drpcategory.DataSource = ds2; drpcategory.DataValueField = "subCatID"; drpcategory.DataTextField = "subCatName"; drpcategory.DataBind(); }
public static void EditingSubCategory(int id, string description) { try { var subcategoryBLL = new SubCategoryBLL(); subcategoryBLL.EditSubCategory(id, description); } catch (Exception ex) { throw ex; } }
public static void AddingSubCategory(string description, int category) { try { var subcategoryBLL = new SubCategoryBLL(); var categoryBLL = new CategoryBLL(); subcategoryBLL.AddSubCategory(description, category); //Agregamos subcategorĂa y vinculamos con categoria } catch (Exception ex) { throw ex; } }
private void GetSubCategoryDetails() { SubCategoryBLL SubCategoryBLLobj = new SubCategoryBLL(); int SUBCATEGORYID = 0; if (ViewState["BGT_SUBCATEGORYID"] != null) { SUBCATEGORYID = Convert.ToInt32(ViewState["BGT_SUBCATEGORYID"]); } SubCategoryBO SubCategoryBOobj = new SubCategoryBO(); SubCategoryBOobj = SubCategoryBLLobj.GetSubCategoryById(SUBCATEGORYID); SubcategoryTextBox.Text = SubCategoryBOobj.BGT_SUBCATEGORYNAME; }
protected void SubCategoryDisplayGrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { SubCategoryBLL subCategoryManager = new SubCategoryBLL(); Label ID = (Label)SubCategoryDisplayGrid.Rows[e.RowIndex].FindControl("lblSubCat_ID"); int selectedId = int.Parse(ID.Text); SubCategory subCategoryToDelete = new SubCategory();//= empid.Text; subCategoryToDelete.SubCategoryID = selectedId; subCategoryManager.Delete(subCategoryToDelete); } catch (Exception exp) { } finally { SubCategoryDisplayGrid.EditIndex = -1; BindGrid(false); } }
protected void SubCategoryDisplayGrid_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName.Equals("Add")) { SubCategoryBLL subCategoryManager = new SubCategoryBLL(); TextBox txtname = (TextBox)SubCategoryDisplayGrid.FooterRow.FindControl("txtAddname"); string catName = ((DropDownList)(SubCategoryDisplayGrid.FooterRow.FindControl("ddlAddCategoryName"))).SelectedItem.Text; string depName = ((DropDownList)(SubCategoryDisplayGrid.FooterRow.FindControl("ddlAddDepName"))).SelectedItem.Text; SubCategory subCategoryToAdd = new SubCategory(); subCategoryToAdd.Name = txtname.Text; subCategoryToAdd.CategoryName = catName; subCategoryToAdd.DepartmentName = depName; subCategoryManager.Add(subCategoryToAdd); } else if (e.CommandName.Equals("UpdateSubCategory")) { SubCategoryBLL subCategoryManager = new SubCategoryBLL(); Label id = (Label)SubCategoryDisplayGrid.Rows[SubCategoryDisplayGrid.EditIndex].FindControl("lblSubCat_ID"); TextBox name = (TextBox)SubCategoryDisplayGrid.Rows[SubCategoryDisplayGrid.EditIndex].FindControl("txtname"); DropDownList ddlCat = (DropDownList)(SubCategoryDisplayGrid.Rows[SubCategoryDisplayGrid.EditIndex].FindControl("ddlCategoryName")); string catName = ddlCat.SelectedItem.Text; DropDownList ddlDep = (DropDownList)(SubCategoryDisplayGrid.Rows[SubCategoryDisplayGrid.EditIndex].FindControl("ddlDepName")); string depName = ddlDep.SelectedItem.Text; int selectedId = int.Parse(id.Text); SubCategory subCategoryToUpdate = new SubCategory();//= empid.Text; subCategoryToUpdate.SubCategoryID = selectedId; subCategoryToUpdate.Name = name.Text; subCategoryToUpdate.CategoryName = catName; subCategoryToUpdate.DepartmentName = depName; subCategoryManager.Update(subCategoryToUpdate); } } catch (Exception exp) { } finally { SubCategoryDisplayGrid.EditIndex = -1; BindGrid(false); } }
private void BindGrid(bool isSearch) { //if (ddlSubCatName.SelectedIndex != -1 && isSearch) //{ // SubCategoryBLL sub = new SubCategoryBLL(); // SubCategory obj = new SubCategory(); // obj.SubCategoryID = int.Parse(ddlSubCatName.SelectedValue); // ds = sub.GetById(obj); //} //else { ds = SubCategoryBLL.GetAllSubCategories(connection); } SubCategoryDisplayGrid.DataSource = ds; SubCategoryDisplayGrid.DataBind(); DropDownList catList = (DropDownList)SubCategoryDisplayGrid.FooterRow.FindControl("ddlAddCategoryName"); catList.DataSource = CategoryBLL.GetDistinct(connection); catList.DataBind(); catList.DataTextField = "categoryName"; //catList.DataValueField = "categoryID"; catList.DataBind(); DropDownList depList = (DropDownList)SubCategoryDisplayGrid.FooterRow.FindControl("ddlAddDepName"); string catId = ((DropDownList)(SubCategoryDisplayGrid.FooterRow.FindControl("ddlAddCategoryName"))).SelectedItem.Text; Category obj2 = new Category(); obj2.Name = catId; CategoryBLL ins = new CategoryBLL(); depList.DataSource = ins.GetDepListByCategoryName(obj2, connection); depList.DataBind(); depList.DataTextField = "Name"; depList.DataValueField = "DepId"; depList.DataBind(); }
/// <summary> /// Used to save details to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string AlertMessage = string.Empty; string message = string.Empty; if (ViewState["BGT_SUBCATEGORYID"].ToString() == "0") { SubCategoryBLL SubCategoryBLLobj = new SubCategoryBLL(); try { string uID = Session["USER_ID"].ToString(); SubCategoryBO SubCategoryBOobj = new SubCategoryBO(); SubCategoryBOobj.BGT_SUBCATEGORYNAME = SubcategoryTextBox.Text.ToString().Trim(); SubCategoryBOobj.BGT_CATEGORYID = Convert.ToInt32(Convert.ToInt32(ViewState["BGT_CATEGORYID"])); SubCategoryBOobj.ACCOUNTCODE = txtAccountCode.Text.Trim(); SubCategoryBOobj.CREATEDBY = Convert.ToInt32(uID); SubCategoryBLL BLLobj = new SubCategoryBLL(); message = BLLobj.Insert(SubCategoryBOobj); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data saved successfully"; ClearAll(); BindGrid(true, true); } } catch (Exception ex) { throw ex; } finally { SubCategoryBLLobj = null; } } else { SubCategoryBLL SubCategoryBLLobj = new SubCategoryBLL(); try { string uID = Session["USER_ID"].ToString(); SubCategoryBO SubCategoryBOobj = new SubCategoryBO(); SubCategoryBOobj.BGT_SUBCATEGORYNAME = SubcategoryTextBox.Text.ToString().Trim(); SubCategoryBOobj.BGT_SUBCATEGORYID = Convert.ToInt32(ViewState["BGT_SUBCATEGORYID"]); SubCategoryBOobj.ACCOUNTCODE = txtAccountCode.Text.Trim(); SubCategoryBOobj.CREATEDBY = Convert.ToInt32(uID); SubCategoryBLL BLLobj = new SubCategoryBLL(); message = BLLobj.Edit(SubCategoryBOobj); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; ClearAll(); BindGrid(true, true); SetUpdateMode(false); } } catch (Exception ex) { throw ex; } finally { SubCategoryBLLobj = null; } } AlertMessage = "alert('" + message + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); }