public static List <ATTMenu> GetMenuList(int appID, int formID, int menuID) { try { List <ATTMenu> lst = new List <ATTMenu>(); foreach (DataRow row in DLLMenu.GetMenuTable(appID, formID, menuID).Rows) { ATTMenu menu = new ATTMenu ( int.Parse(row["Appl_ID"].ToString()), int.Parse(row["Form_ID"].ToString()), int.Parse(row["Menu_ID"].ToString()), (string)row["Menu_Name"], row["Menu_Description"].ToString(), row["P_SELECT"].ToString(), row["P_ADD"].ToString(), row["P_EDIT"].ToString(), row["P_DELETE"].ToString(), "M" ); lst.Add(menu); } return(lst); } catch (Exception ex) { throw ex; } }
public static ObjectValidation Validate(ATTMenu obj) { ObjectValidation OV = new ObjectValidation(); if (obj.MenuName == "") { OV.IsValid = false; OV.ErrorMessage = "Menu name cannot be blank."; return(OV); } return(OV); }
protected void btnAddMenu_Click(object sender, EventArgs e) { if (this.grdForm.SelectedIndex < 0) { this.lblStatus.Text = "Please select any form form table."; return; } if (this.grdMenu.Rows.Count > 1) { this.lblStatus.Text = "Only one menu for one form."; return; } List <ATTApplication> lstApp = (List <ATTApplication>)Session["LstAppFM"]; List <ATTApplicationForm> lstForm = lstApp[this.ddlApplication_Rqd.SelectedIndex].LstApplicationForm; List <ATTMenu> lstMenu = lstForm[this.grdForm.SelectedIndex].LstMenu; ATTMenu appMenu = new ATTMenu ( lstApp[this.ddlApplication_Rqd.SelectedIndex].ApplicationID, lstForm[this.grdForm.SelectedIndex].FormID, 0, this.txtMenuName_Rqd.Text, this.txtMenuDesc.Text, (this.chkSelect.Checked == true) ? "Y" : "N", (this.chkAdd.Checked == true) ? "Y" : "N", (this.chkEdit.Checked == true) ? "Y" : "N", (this.chkDelete.Checked == true) ? "Y" : "N", "A" ); ObjectValidation OV = BLLMenu.Validate(appMenu); if (OV.IsValid == false) { this.lblStatus.Text = OV.ErrorMessage; return; } lstMenu.Add(appMenu); this.grdMenu.DataSource = lstMenu; this.grdMenu.DataBind(); this.ClearMenuControls(); }