protected void grdItemCategoryMaster_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("ADD")) { DropDownList ddlNewCategoryGroupCode = (DropDownList)grdItemCategoryMaster.FooterRow.FindControl("ddlNewCategoryGroupCode"); DropDownList ddlNewCanteenName = (DropDownList)grdItemCategoryMaster.FooterRow.FindControl("ddlNewCanteenName"); TextBox txtNewItemCategoryName = (TextBox)grdItemCategoryMaster.FooterRow.FindControl("txtNewItemCategoryName"); CheckBox ChStatusNew = (CheckBox)grdItemCategoryMaster.FooterRow.FindControl("ChStatusNew"); DropDownList ddlNewStartTime = (DropDownList)grdItemCategoryMaster.FooterRow.FindControl("ddlNewStartTime"); DropDownList ddlNewEndTime = (DropDownList)grdItemCategoryMaster.FooterRow.FindControl("ddlNewEndTime"); if (IsValid) { //errNumber = -1; try { objBusinessClass = new BusinessLayer.BusinessClass(); objML_ItemCategoryMaster = new ML_ItemCategoryMaster(); objML_ItemCategoryMaster.CategoryGroupCode = Convert.ToInt32(ML_Common.clean(ddlNewCategoryGroupCode.SelectedValue)); objML_ItemCategoryMaster.CanteenCode = Convert.ToInt32(ML_Common.clean(ddlNewCanteenName.SelectedValue)); objML_ItemCategoryMaster.ItemCategoryName = ML_Common.clean(txtNewItemCategoryName.Text); objML_ItemCategoryMaster.StartTime = Convert.ToDateTime(ML_Common.clean(ddlNewStartTime.SelectedValue)); objML_ItemCategoryMaster.EndTime = Convert.ToDateTime(ML_Common.clean(ddlNewEndTime.Text)); if (ChStatusNew.Checked) { objML_ItemCategoryMaster.ItemCategoryActive = 1; } else { objML_ItemCategoryMaster.ItemCategoryActive = 0; } int obhReturn = objBusinessClass.AddItemCategoryMaster(objML_ItemCategoryMaster); if (obhReturn == 1) { lblMsg.Visible = true; lblMsg.Text = "Record Saved Successfully"; FillGrid(); } else if (obhReturn == 2) { lblMsg.Text = "Record Already Exists!"; lblMsg.Visible = true; } } catch (SqlException sqlExc) { // LogManager.LogManager.WriteErrorLog(sqlExc); SqlException sqlEt = sqlExc; return; } catch (Exception ex) { Exception exc = ex;// Exception exc=ex;// LogManager.LogManager.WriteErrorLog(ex); } } } }
protected void grdItemCategoryMaster_RowUpdating(object sender, GridViewUpdateEventArgs e) { DropDownList ddlNewCategoryGroupCode = (DropDownList)grdItemCategoryMaster.Rows[e.RowIndex].FindControl("ddlNewCategoryGroupCode"); DropDownList ddlNewCanteenName = (DropDownList)grdItemCategoryMaster.Rows[e.RowIndex].FindControl("ddlNewCanteenName"); TextBox txtNewItemCategoryName = (TextBox)grdItemCategoryMaster.Rows[e.RowIndex].FindControl("txtNewItemCategoryName"); CheckBox ChStatusNew = (CheckBox)grdItemCategoryMaster.Rows[e.RowIndex].FindControl("ChStatusNew"); DropDownList ddlNewStartTime = (DropDownList)grdItemCategoryMaster.Rows[e.RowIndex].FindControl("ddlNewStartTime"); DropDownList ddlNewEndTime = (DropDownList)grdItemCategoryMaster.Rows[e.RowIndex].FindControl("ddlNewEndTime"); if (IsValid) { //errNumber = -1; BusinessClass objBusinessClass = new BusinessLayer.BusinessClass(); int lngId = ML_Common.string2int(grdItemCategoryMaster.DataKeys[e.RowIndex].Values[0].ToString()); ML_ItemCategoryMaster objML_ItemCategoryMaster = objBusinessClass.GetItemCategoryMasterByItemCategoryCode(lngId); try { if (objML_ItemCategoryMaster != null) { objML_ItemCategoryMaster.CategoryGroupCode = Convert.ToInt32(ML_Common.clean(ddlNewCategoryGroupCode.SelectedValue)); objML_ItemCategoryMaster.CanteenCode = Convert.ToInt32(ML_Common.clean(ddlNewCanteenName.SelectedValue)); objML_ItemCategoryMaster.ItemCategoryName = ML_Common.clean(txtNewItemCategoryName.Text); objML_ItemCategoryMaster.StartTime = Convert.ToDateTime(ML_Common.clean(ddlNewStartTime.SelectedValue)); objML_ItemCategoryMaster.EndTime = Convert.ToDateTime(ML_Common.clean(ddlNewEndTime.Text)); if (ChStatusNew.Checked) { objML_ItemCategoryMaster.ItemCategoryActive = 1; } else { objML_ItemCategoryMaster.ItemCategoryActive = 0; } int obhReturn = objBusinessClass.UpdateItemCategoryMaster(objML_ItemCategoryMaster); if (obhReturn == 1) { lblMsg.Visible = true; lblMsg.Text = "Record Update Successfully"; } else if (obhReturn == 2) { lblMsg.Text = "Ooops!OtherIssue..."; lblMsg.Visible = true; } else { lblMsg.Text = "Ooops!OtherIssue..."; lblMsg.Visible = true; } grdItemCategoryMaster.EditIndex = -1; FillGrid(); } } catch (SqlException sqlExc) { SqlException sqlEt = sqlExc; return; } catch (Exception ex) { Exception exc = ex;// LogManager.LogManager.WriteErrorLog(ex); } } }