protected void subcategorygrdvw_RowUpdating(object sender, GridViewUpdateEventArgs e) { int subcategoryid = 0; string name, desc, id; int FlagCount; name = ((TextBox)subcategorygrdvw.Rows[e.RowIndex].Cells[1].Controls[0]).Text; desc = ((TextBox)subcategorygrdvw.Rows[e.RowIndex].Cells[2].Controls[0]).Text; id = Convert.ToString(subcategorygrdvw.Rows[e.RowIndex].Cells[0].Text); //DropDownList categorydrp = ((DropDownList)subcategorygrdvw.Rows[e.RowIndex].Cells[4].FindControl("drpcategoryname")); int categoryid = Convert.ToInt32(drpCategory.SelectedValue); subcategoryid = Convert.ToInt32(id); ObjSubcategory = ObjSubcategory.Get_By_id(subcategoryid); FlagCount = ObjSubcategory.Get_By_SubcategoryName(name, categoryid); if ((FlagCount == 0) && (name != "")) { ObjSubcategory.Categoryid = categoryid; ObjSubcategory.Subcategoryid = subcategoryid; ObjSubcategory.Subcategoryname = name; ObjSubcategory.Subcategorydescription = desc; ObjSubcategory.Update(); subcategorygrdvw.EditIndex = -1; BindGrid(); lblerrmsg.Text = Resources.MessageResource.errupdate.ToString(); } else if (ObjSubcategory.Subcategoryname == name) { ObjSubcategory.Categoryid = categoryid; ObjSubcategory.Subcategoryid = subcategoryid; ObjSubcategory.Subcategoryname = name; ObjSubcategory.Subcategorydescription = desc; ObjSubcategory.Update(); subcategorygrdvw.EditIndex = -1; BindGrid(); lblerrmsg.Text = Resources.MessageResource.errupdate.ToString(); } else if (name == "") { lblerrmsg.Text = Resources.MessageResource.errnotempty.ToString(); } else { lblerrmsg.Text = Resources.MessageResource.errSubcategoryExist.ToString(); } }
protected void btnSubcategoryadd_Click(object sender, EventArgs e) { int subcategoryid = 0; int varCategoryid; varCategoryid = Convert.ToInt32(drpCategory.SelectedValue); subcategoryid = ObjSubcategory.Get_By_SubcategoryName(txtSubcategoryName.Text.ToString(), varCategoryid); if (subcategoryid == 0) { ObjSubcategory.Subcategoryname = txtSubcategoryName.Text.ToString(); ObjSubcategory.Categoryid = Convert.ToInt32(drpCategory.SelectedValue); ObjSubcategory.Subcategorydescription = txtSubcategorydesc.Text.ToString(); ObjSubcategory.Insert(); BindGrid(); lblerrmsg.Text = Resources.MessageResource.errsubcategorysave.ToString(); } else { lblerrmsg.Text = Resources.MessageResource.errSubcategoryExist.ToString(); } }
protected void subcategorygrdvw_RowUpdating(object sender, GridViewUpdateEventArgs e) { int subcategoryid = 0; string name, desc, id; int FlagCount; name = ((TextBox)subcategorygrdvw.Rows[e.RowIndex].Cells[1].Controls[0]).Text; desc = ((TextBox)subcategorygrdvw.Rows[e.RowIndex].Cells[2].Controls[0]).Text; id = Convert.ToString(subcategorygrdvw.Rows[e.RowIndex].Cells[0].Text); //DropDownList categorydrp = ((DropDownList)subcategorygrdvw.Rows[e.RowIndex].Cells[4].FindControl("drpcategoryname")); int categoryid = Convert.ToInt32(drpCategory.SelectedValue); subcategoryid = Convert.ToInt32(id); ObjSubcategory = ObjSubcategory.Get_By_id(subcategoryid); FlagCount = ObjSubcategory.Get_By_SubcategoryName(name, categoryid); if ((FlagCount == 0)&&(name!="")) { ObjSubcategory.Categoryid = categoryid; ObjSubcategory.Subcategoryid = subcategoryid; ObjSubcategory.Subcategoryname = name; ObjSubcategory.Subcategorydescription = desc; ObjSubcategory.Update(); subcategorygrdvw.EditIndex = -1; BindGrid(); lblerrmsg.Text = Resources.MessageResource.errupdate.ToString(); } else if (ObjSubcategory.Subcategoryname == name) { ObjSubcategory.Categoryid = categoryid; ObjSubcategory.Subcategoryid = subcategoryid; ObjSubcategory.Subcategoryname = name; ObjSubcategory.Subcategorydescription = desc; ObjSubcategory.Update(); subcategorygrdvw.EditIndex = -1; BindGrid(); lblerrmsg.Text = Resources.MessageResource.errupdate.ToString(); } else if (name == "") { lblerrmsg.Text = Resources.MessageResource.errnotempty.ToString(); } else { lblerrmsg.Text = Resources.MessageResource.errSubcategoryExist.ToString(); } }