protected void GrdReport_ItemCommand(object source, RepeaterCommandEventArgs e) { try { switch (e.CommandName) { case ("Select"): { if (Convert.ToInt32(e.CommandArgument) != 0) { ViewState["EditID"] = Convert.ToInt32(e.CommandArgument); DS = Obj_IS.GetSubCategoryForEdit(Convert.ToInt32(e.CommandArgument), out StrError); if (DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0) { TxtItemSubCat.Text = DS.Tables[0].Rows[0]["SubCategory"].ToString(); ddlCategory.SelectedValue = DS.Tables[0].Rows[0]["CategoryID"].ToString(); txtRemark.Text = DS.Tables[0].Rows[0]["Remark"].ToString(); } else { MakeEmptyForm(); } DS = null; Obj_IS = null; if (!FlagEdit) { BtnUpdate.Visible = true; } BtnSave.Visible = false; if (!FlagDel) { BtnDelete.Visible = true; } TxtItemSubCat.Focus(); } break; } } } catch (Exception ex) { StrError = ex.Message; } }
protected void BtnSave_Click(object sender, EventArgs e) { int InsertRow = 0; try { DS = Obj_IS.ChkDuplicate(TxtItemSubCat.Text.Trim(), out StrError); if (DS.Tables[0].Rows.Count > 0) { Obj_comm.ShowPopUpMsg("This Sub Category Is Already Exist....", this.Page); TxtItemSubCat.Focus(); } else { Entity_IS.SubCategoryName = TxtItemSubCat.Text.Trim(); Entity_IS.CategoryId = Convert.ToInt32(ddlCategory.SelectedValue.ToString()); Entity_IS.UserId = Convert.ToInt32(Session["userId"]); Entity_IS.LoginDate = DateTime.Now; Entity_IS.IsDeleted = false; Entity_IS.Remark = txtRemark.Text.Trim(); InsertRow = Obj_IS.InsertRecord(ref Entity_IS, out StrError); if (InsertRow != 0) { Obj_comm.ShowPopUpMsg("Record Saved successfully", this.Page); MakeEmptyForm(); Entity_IS = null; Obj_comm = null; } } } catch (Exception ex) { throw new Exception(ex.Message); } }