protected void Page_Load(object sender, EventArgs e) { selectnode(); //SelectedNode = TreeView1.SelectedNode.Text; //TreeView1.Nodes node = TreeView1.FindNode("NMBM").Text; //TreeView1.SelectedNode.Text = TreeView1.FindNode("NMBM").Text; //TreeView1.FindNode("NMBM"); clsUser LogedinUser = new clsUser(); List<clspageobj> ChkList = new List<clspageobj>(); ChkList= LogedinUser.UserRolesObj(Session["UserPkid"].ToString(), Session["UserRolePkid"].ToString(), Session["UserLocationPkid"].ToString()); var b = from ch in ChkList where ch.obj_name == "wpaLocationDetails.aspx" select ch.obj_status; bool testFrmval = (bool)b.Single(); var SaveBtn = from ch in ChkList where ch.obj_name == "btnMulSave" select ch.obj_status; bool testSaveBtntval = (bool)SaveBtn.Single(); if (!(bool)SaveBtn.Single()) { btnMulSave.Enabled = false; } if (IsPostBack) { } if (!IsPostBack) { Addnew(); fill_Tree2(); addparenttolist(); TreeView1.ExpandAll(); pnlright.Enabled = false; rightpanelbtn(false); leftpanelbtn(true); msgmulliteral.Text = ""; clsUser MyUser = new clsUser(); MyUser.BrowseUser(ddlmanager); } //retriveolddata(SelectedNode); setPageProperties("wpaLocationsDetails"); } public bool checkFileExtension(string fname) { if (fname.IndexOf(".") == -1) return false; string[] validExtensions = new string[5]; string ext = fname.Substring(fname.LastIndexOf('.') + 1).ToLower(); //Add valid extentions in this array validExtensions[0] = "jpg"; //validExtensions[1] = 'pdf'; for (int i = 0; i < validExtensions.Length; i++) { if (ext == validExtensions[0].ToString()) return true; } return false; } IMA.DataClasses1DataContext forselectdb = new IMA.DataClasses1DataContext(); private void Addnew() { //For getting the LocationID string test = string.Empty; var nodes = from nd in forselectdb.tbllocations orderby nd.locid descending select new { nd.locid, nd.locname, nd.locparentid, nd.locshortdesc }; foreach (var lo in nodes.Take(1)) { test = lo.locid.ToString(); } string a = ""; int tempid = Convert.ToInt32(test.Remove(0, 2)) + 1; if (tempid < 10) { a = "AA000" + tempid.ToString(); } else if (tempid < 100) { a = "AA00" + tempid.ToString(); } else if (tempid < 1000) { a = "AA0" + tempid.ToString(); } else if (tempid < 10000) { a = "AA" + tempid.ToString(); } txtMunicipalID.Text = a.ToString(); txtMunicipalID.DataBind(); } public clsLocation mylocation = new clsLocation(); protected void btnMulSave_Click(object sender, ImageClickEventArgs e) { if (txtMulName.Text == "") { string str1 = "Name field cannot be left blank!!!"; ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + str1 + "');", true); } else { if (txtMulName.Text == ddlparent.Text) { msgmulliteral.Text = "Municipal Name and its Parent Node cannot be same."; } else { if (fileup.HasFile) { file = fileup.FileName; bool ans = checkFileExtension(file); if (ans) { try { fileadd = (Server.MapPath("Image\\") + txtMulShortName.Text + "." + file.Substring(file.LastIndexOf(".") + 1).ToString()); fileup.SaveAs(fileadd); } catch (Exception ex) { } locLogo.ImageUrl = "~/Image/" + txtMulName.Text + "." + file.Substring(file.LastIndexOf(".") + 1).ToString(); } else { msgmulliteral.Text = "Invalid file type of Logo, select only JPG files"; }</clspageobj></clspageobj>
fileadd = (Server.MapPath("Image\\") + txtMulShortName.Text + "." + file.Substring(file.LastIndexOf(".") + 1).ToString()); fileup.SaveAs(fileadd);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)