public static DropDownList FillddlMainMenu(DropDownList ddl, int EVENT, int ID, string CODE) { ddl.Items.Clear(); var dt = BL_MainMenu.GetMainMenu(EVENT, ID, CODE); if (dt.Rows.Count > 0) { ddl.DataSource = dt; ddl.DataValueField = "MainMenuID"; ddl.DataTextField = "MenuName"; ddl.DataBind(); ddl.Items.Insert(0, new ListItem("Select", "0", true)); } return(ddl); }
private void FillgvMenu() { var dt = new DataTable(); dt = BL_MainMenu.GetMainMenu(1, 0, ""); if (dt.Rows.Count > 0) { gvMenu.DataSource = dt; gvMenu.DataBind(); } else { gvMenu.DataSource = new string[] { }; gvMenu.DataBind(); } }
private void InsupdDeleteMenu(char Event, int Id) { var obj = new BL_MainMenu(); Session["UserId"] = 0; if (txtOrder.Text != "") { obj.Odr = Convert.ToInt32((string)txtOrder.Text); } if (Event == 'D') { obj.EVENT = Event; obj.MainMenuID = Id; var msg = ""; msg = obj.InsUpdDeleteMainMenu(out Id); if (msg == "Record Deleted Successfully") { msgbox.ShowSuccess(msg); } else { msgbox.ShowWarning(msg); } } else if (CheckValidFile()) { if (Event == 'I') { obj.EVENT = Event; obj.MainMenuID = 0; obj.MenuName = txtMenuName.Text; obj.ImageURL = fuImage.PostedFile.FileName; if ((fuImage.PostedFile != null) && (fuImage.PostedFile.ContentLength > 0)) { var fn = System.IO.Path.GetFileName(fuImage.PostedFile.FileName); var SaveLocation = Server.MapPath("~/Images") + "\\" + fn; obj.ImageURL = "~/Images/" + fn; try { fuImage.PostedFile.SaveAs(SaveLocation); } catch (Exception ex) { msgbox.ShowWarning("Error: " + ex.Message); //Note: Exception.Message returns a detailed message that describes the current exception. //For security reasons, we do not recommend that you return Exception.Message to end users in //production environments. It would be better to put a generic error message. } } Id = 0; var msg = ""; msg = obj.InsUpdDeleteMainMenu(out Id); if (msg == "Record Inserted Successfully") { msgbox.ShowSuccess(msg); } else { msgbox.ShowWarning(msg); } } else if (Event == 'U') { obj.EVENT = Event; obj.MainMenuID = Id; obj.MenuName = txtMenuName.Text; if ((fuImage.PostedFile != null) && (fuImage.PostedFile.ContentLength > 0)) { var fn = System.IO.Path.GetFileName(fuImage.PostedFile.FileName); var SaveLocation = Server.MapPath("~/Images") + "\\" + fn; obj.ImageURL = "~/Images/" + fn; try { fuImage.PostedFile.SaveAs(SaveLocation); Response.Write("The file has been uploaded."); } catch (Exception ex) { Response.Write("Error: " + ex.Message); //Note: Exception.Message returns a detailed message that describes the current exception. //For security reasons, we do not recommend that you return Exception.Message to end users in //production environments. It would be better to put a generic error message. } } var msg = ""; msg = obj.InsUpdDeleteMainMenu(out Id); if (msg == "Record Updated Successfully") { msgbox.ShowSuccess(msg); } else { msgbox.ShowWarning(msg); } } } btnMenu.Text = "Save"; btnMenu.CommandName = "Save"; txtMenuName.Text = ""; FillgvMenu(); }