TechEthical CEHP

Current Path : G:/PleskVhosts/megamind.net.in/careercentre360.com/admin/
Upload File :
Current File : G:/PleskVhosts/megamind.net.in/careercentre360.com/admin/UpdateSubMenu.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Directory;
using System.Data;
using System.Data.SqlClient;

namespace Bathuasoft.admin
{
	public partial class UpdateSubMenu : System.Web.UI.Page
	{
        public System.Data.DataTable dt = new System.Data.DataTable();
        public System.Data.SqlClient.SqlDataAdapter SqlAdapter = new SqlDataAdapter();
        public string ImagePath="" ;

		protected void Page_Load(object sender, EventArgs e)
		{
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            if (!IsPostBack)
            {
                if (Session["Loginxtr"].ToString() != "1254lkjhhfdgftfrdgf")
                {
                    Response.Redirect("login.aspx");
                }

                PopulateDS();        // FILL DATASET WITH MASTER DATA.                
            }
		}

        private void PopulateDS()
        {
            dt.Clear();
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            dt = obj.getDataTable(@"SELECT distinct concat(Menu, ' : ', submenu) as menues 
                from dbo.[tbl_SubMenu] where status='Active' order by concat(Menu, ' : ', submenu)  ");
            cmbMenu.Items.Add("---Select Menu Options---");

            for (int i=0; i<dt.Rows.Count; i++)
            {
                cmbMenu.Items.Add(dt.Rows[i]["Menues"].ToString());
            }
        }

        protected void btnUploadInContents_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string FileName = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
                string FilePath = "../img/Gallery/Amenties/" + FileName;
                FileUpload1.SaveAs(Server.MapPath(FilePath));
                txtFullContents.Text += string.Format("<img src = '{0}' alt = '{1}' />", FilePath, FileName);
            }
        }

        protected void btnMainImageFileUpload_Click(object sender, EventArgs e)
        {
            if (fuMainImageFileSelect.HasFile)
            {
                string FileName = System.IO.Path.GetFileName(fuMainImageFileSelect.PostedFile.FileName);
                ImagePath = "../img/Menu/" +  cmbMenu.Text.Replace(":", "-") + ".png";
                fuMainImageFileSelect.SaveAs(Server.MapPath(ImagePath));
                imgMainImage.ImageUrl = ImagePath;
                connection_sql obj = new connection_sql();
                obj.MakeConnection();
                string qry = "";
                int n = 0;
                qry = " Update tbl_Submenu set ImagePath='" + ImagePath + "'"
                    + " where concat(Menu, ' : ', submenu) ='" + cmbMenu.Text + "'";
                lblMainImagePath.Text = ImagePath;
                n=obj.ExcuteCommand(qry);
                obj.CloseConnection();

                if (n==1)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "set", "alert('Main Image Uploaded');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "set", "alert('Error: Main Image not uploading');", true);
                }                   
            }
        }
        
        protected void butSubmit_Click(object sender, EventArgs e)
        {
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            int n = 0;
            SqlCommand cmd = new SqlCommand("[sp_SavePageContant]", obj.conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@MenuSubmenu", cmbMenu.Text.Trim());
            cmd.Parameters.AddWithValue("@PageTitle", txtPageTitle.Text.Trim());
            cmd.Parameters.AddWithValue("@Heading", txtHeading.Text.Trim());
            cmd.Parameters.AddWithValue("@ShortContents", txtShortContents.Text.Trim());
            cmd.Parameters.AddWithValue("@FullContants", txtFullContents.Text);
            cmd.Parameters.AddWithValue("@ImagePath", lblMainImagePath.Text);
            n=cmd.ExecuteNonQuery();
            obj.CloseConnection();
            
            if (n==1)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "set", "alert('Save Successfully...');", true);
            }
        }

        protected void cmbMenu_SelectedIndexChanged(object sender, EventArgs e)
        {
           

            dt.Clear();
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            dt = obj.getDataTable(@"SELECT * from [dbo].[tbl_SubMenu] 
                    where concat(Menu, ' : ', submenu) ='" + cmbMenu.Text + "'");

            if (dt.Rows.Count==1)
            {
                if (dt.Rows[0]["Heading"].ToString() != null)
                    txtHeading.Text =dt.Rows[0]["Heading"].ToString();

                if (dt.Rows[0]["ShortContents"].ToString() != null)
                    txtShortContents.Text =dt.Rows[0]["ShortContents"].ToString();

                if (dt.Rows[0]["Contents"].ToString() != null)
                    txtFullContents.Text =dt.Rows[0]["Contents"].ToString();

                if (dt.Rows[0]["ImagePath"].ToString() != null)
                {
                    ImagePath = dt.Rows[0]["ImagePath"].ToString();
                }
                else
                {
                    ImagePath = "../img/Menu/" + cmbMenu.Text.Replace(":", "-") + ".png";                    
                }
                imgMainImage.ImageUrl = ImagePath;
            }


        }
	}

    
}

TechEthical Mini WebShell Version 1.0, Coded By The_M@T3