public int UpdateSubMenu(SubMenuEntity oMenuEntity) { con = oConnectionDatabase.DatabaseConnection(); try { con.Open(); } catch { } int i = 0; //cmd = new SqlCommand("INSERT INTO tblCustomerImage (CustomerID,CustomerImage,CustomerSignature,Creatby,LastModifiedBy) VALUES('" + customerId + "','" + image + "','" + signature + "','" + Creatby + "','" + LastModifiedBy + "')", con); cmd = new SqlCommand("UPDATE tblSubMenuItem SET SubMenuName=@SubMenuName,LastModifiedBy=@LastModifiedBy where MenuNo=@MenuNo and SubMenuNo=@SubMenuNo", con); //cmd = new SqlCommand("INSERT INTO tblUserInfo (UserID,UserType,Password,ConfirmPassword,Active,LastModifiedBy) VALUES(@UserID,@UserType,@Password,@ConfirmPassword,@Active,@LastModifiedBy)", con); cmd.Parameters.AddWithValue("@SubMenuNo", SqlDbType.VarChar).Value = oMenuEntity.SubMenuNo; cmd.Parameters.AddWithValue("@SubMenuName", SqlDbType.Image).Value = oMenuEntity.SubMenuName; cmd.Parameters.AddWithValue("@MenuNo", SqlDbType.VarChar).Value = oMenuEntity.MenuNo; cmd.Parameters.AddWithValue("@LastModifiedBy", SqlDbType.Image).Value = oMenuEntity.LastModifiedBy; try { cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); i = 1; } catch { } con.Close(); return(i); }
public int InsertSubMenu(SubMenuEntity oMenuEntity) { con = oConnectionDatabase.DatabaseConnection(); try { con.Open(); } catch { } int i = 0; //cmd = new SqlCommand("INSERT INTO tblCustomerImage (CustomerID,CustomerImage,CustomerSignature,Creatby,LastModifiedBy) VALUES('" + customerId + "','" + image + "','" + signature + "','" + Creatby + "','" + LastModifiedBy + "')", con); cmd = new SqlCommand("INSERT INTO tblSubMenuItem (SubMenuNo,SubMenuName,MenuNo,CreateBy,LastModifiedBy) VALUES(@SubMenuNo,@SubMenuName,@MenuNo,@CreateBy,@LastModifiedBy)", con); cmd.Parameters.AddWithValue("@SubMenuNo", SqlDbType.VarChar).Value = oMenuEntity.SubMenuNo; cmd.Parameters.AddWithValue("@SubMenuName", SqlDbType.Image).Value = oMenuEntity.SubMenuName; cmd.Parameters.AddWithValue("@MenuNo", SqlDbType.VarChar).Value = oMenuEntity.MenuNo; cmd.Parameters.AddWithValue("@CreateBy", SqlDbType.VarChar).Value = oMenuEntity.CreateBy; cmd.Parameters.AddWithValue("@LastModifiedBy", SqlDbType.Image).Value = oMenuEntity.LastModifiedBy; try { cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); i = 1; } catch { } con.Close(); return(i); }
void DisplayChildMenuText(MenuItem item) { SubMenuEntity oMenu = new SubMenuEntity(); oMenu.SubMenuName = item.Text; oMenu.SubMenuNo = (k++).ToString(); oMenu.MenuNo = menuItemDropDownList.SelectedValue; oSubMenuList.Add(oMenu); foreach (MenuItem childItem in item.ChildItems) { DisplayChildMenuText(childItem); } }
public int DeleteSubMenu(SubMenuEntity oMenuEntity) { con = oConnectionDatabase.DatabaseConnection(); int i = 0; cmd = new SqlCommand("DELETE FROM tblSubMenuItem WHERE SubMenuNo='" + oMenuEntity.SubMenuNo + "' and MenuNo='" + oMenuEntity.MenuNo + "'", con); //cmd = new SqlCommand("DELETE FROM tblSubMenuItem", con); try { cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); i = 1; } catch { } con.Close(); return(i); }
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); } } }
public int InsertMainMenu(SubMenuEntity ObjSubMenuEntity, char Operation) { Hashtable ht = new Hashtable(); if (Operation == 'I') { ht.Add("@SubMenuID", 0); } else { ht.Add("@SubMenuID", ObjSubMenuEntity.SubMenuID); } ht.Add("@MainMenuID", ObjSubMenuEntity.MainMenuID); ht.Add("@SubMenuName", ObjSubMenuEntity.SubMenuName); ht.Add("@Status", ObjSubMenuEntity.Status); ht.Add("@URL", ObjSubMenuEntity.URL); ht.Add("@Operation", Operation); return(objUtilities.ExecuteNonQuery("InsertSubMenuDetails", ht)); }
private void gridViewBind() { Menu NavigationMenu = (Menu)this.Master.FindControl("NavigationMenu"); MenuItem NavigationMenu1 = NavigationMenu.Items[Convert.ToInt16(menuItemDropDownList.SelectedValue)]; //(MenuItem)NavigationMenu.Items[Convert.ToInt16(menuItemDropDownList.SelectedValue)].ChildItems; //List<SubMenuEntity> oSubMenuList = new List<SubMenuEntity>(); SubMenuEntity oMenu = new SubMenuEntity(); foreach (MenuItem item in NavigationMenu1.ChildItems) { // Display the menu items. DisplayChildMenuText(item); } //for (int i = 0; i < count; i++) //{ // oMenu = new SubMenuEntity(); // oMenu.MenuNo = menuItemDropDownList.SelectedValue; // oMenu.SubMenuNo = i.ToString(); // oMenu.SubMenuName = NavigationMenu.Items[Convert.ToInt16(menuItemDropDownList.SelectedValue)].ChildItems[i].Text; // oMenuList.Add(oMenu); //} GridView1.DataSource = oSubMenuList; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] != null) { ReturnVal oRtnValue = new ReturnVal(); string BranchName = oRtnValue.ReturnValue("View_BranchInfo", "userid", "'" + Session["userID"] + "'", "BranchName"); string EmployeeName = oRtnValue.ReturnValue("View_BranchInfo", "userid", "'" + Session["userID"] + "'", "EmployeeName"); Label1.Text = "Branch/Division: " + BranchName; //Label1.Text = BranchName; Label2.Text = "User Name: " + EmployeeName; Label1.Font.Bold = true; Label1.Font.Italic = false; Label1.Font.Name = "verdana"; Label1.Font.Overline = false; Label1.Font.Size = 10; Label1.Font.Strikeout = false; Label1.Font.Underline = false; Label2.Font.Name = "verdana"; } if (Session["user"] == null) { Server.Transfer("WebLogin.aspx"); } if (!IsPostBack) { string condition = " where userID='" + Session["user"].ToString() + "'"; DataTable dt = oUserInfoDAO.GetUserInfo(condition); string userType = ""; if (dt.Rows.Count > 0) { userType = dt.Rows[0]["UserType"].ToString(); if (userType != "Admin") { condition = " where userID='" + Session["user"].ToString() + "'"; DataTable dt1 = oUserAssignRightDAO.GetUserAssignRight(condition); SubMenuEntity oMenu = new SubMenuEntity(); for (int k = 0; k < NavigationMenu.Items.Count; k++) { if (NavigationMenu.Items[k].Text == "Admin") { NavigationMenu.Items[k].Enabled = false; } foreach (MenuItem item in NavigationMenu.Items[k].ChildItems) { // Display the menu items. DisplayChildMenuText(item, dt1); } } } } } }