protected void addButton_Click(object sender, EventArgs e) { MenuAndSubMenuDAO oMenuAndSubMenuDAO = new MenuAndSubMenuDAO(); for (int i = 0; i < menuItemDropDownList.Items.Count; i++) { MenuEntity oMenuEntity = new MenuEntity(); string condition = " where MenuNo='" + menuItemDropDownList.Items[i].Value + "'"; DataTable dt = oMenuAndSubMenuDAO.GetMenu(condition); oMenuEntity.MenuNo = menuItemDropDownList.Items[i].Value; oMenuEntity.MenuName = menuItemDropDownList.Items[i].Text; oMenuEntity.CreateBy = DateTime.Now.ToShortDateString(); oMenuEntity.LastModifiedBy = DateTime.Now.ToShortDateString(); if (dt.Rows.Count > 0) { int j = oMenuAndSubMenuDAO.DeleteMenu(oMenuEntity); } else { int j = oMenuAndSubMenuDAO.InsertMenu(oMenuEntity); } } for (int i = 0; i < GridView1.Rows.Count; i++) { SubMenuEntity oSubMenuEntity = new SubMenuEntity(); //oSubMenuEntity.ID =Convert.ToInt16(((Label)GridView1.Rows[i].FindControl("idLabel")).Text); oSubMenuEntity.SubMenuNo = ((Label)GridView1.Rows[i].FindControl("SubMenuNoLabel")).Text; oSubMenuEntity.SubMenuName = ((Label)GridView1.Rows[i].FindControl("SubMenuNameLabel")).Text; oSubMenuEntity.MenuNo = ((Label)GridView1.Rows[i].FindControl("MenuNoLabel")).Text; oSubMenuEntity.CreateBy = DateTime.Now.ToShortDateString(); oSubMenuEntity.LastModifiedBy = DateTime.Now.ToShortDateString(); string condition = " where SubMenuNo='" + oSubMenuEntity.SubMenuNo + "' and MenuNo='" + oSubMenuEntity.MenuNo + "'"; DataTable dt = oMenuAndSubMenuDAO.GetSubMenu(condition); if (dt.Rows.Count > 0) { int j = oMenuAndSubMenuDAO.DeleteSubMenu(oSubMenuEntity); } else { int j = oMenuAndSubMenuDAO.InsertSubMenu(oSubMenuEntity); } } }
private void loadDropDownList() { string condition = " where tblUserInfo.UserType<>'Admin' and tblUserInfo.Active='true'"; DataTable dt = oUserInfoDAO.GetUserInfo(condition); if (dt.Rows.Count > 0) { userDropDownList.DataSource = dt; userDropDownList.DataTextField = "UserID"; userDropDownList.DataValueField = "UserID"; userDropDownList.DataBind(); } condition = " where MenuName<>'Admin'"; dt = new DataTable(); dt = oMenuAndSubMenuDAO.GetMenu(condition); if (dt.Rows.Count > 0) { menuItemDropDownList.DataSource = dt; menuItemDropDownList.DataTextField = "MenuName"; menuItemDropDownList.DataValueField = "MenuNo"; menuItemDropDownList.DataBind(); } }