TechEthical CEHP

Current Path : G:/PleskVhosts/megamind.net.in/careercentre360.com/admin/
Upload File :
Current File : G:/PleskVhosts/megamind.net.in/careercentre360.com/admin/Menu.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 Menu : 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 Menu as menues 
                from tbl_MainMenu where status='Active' order by Menu ");
            cmbMenu.Items.Add("---Select Menu ---");

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

        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";
                //ImagePath = "../img/Menu/" + cmbMenu.Text.Replace(":", "-") + DateTime.Now.Ticks.ToString() + ".png";
                //ImagePath = "../img/Menu/.png?" + DateTime.Now.Ticks.ToString();
                fuMainImageFileSelect.SaveAs(Server.MapPath(ImagePath));
                imgMainImage.ImageUrl = ImagePath;
                connection_sql obj = new connection_sql();
                obj.MakeConnection();
                string qry = "";
                int n = 0;
                qry = " Update tbl_MainMenu set ContentImage='" + ImagePath + "'"
                    + " where Menu ='" + 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_SaveMenuPageContant]", obj.conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Menu", cmbMenu.Text.Trim());
            cmd.Parameters.AddWithValue("@Heading", txtHeading.Text.Trim());
            cmd.Parameters.AddWithValue("@SubHeading", txtSubHeading.Text.Trim());
            cmd.Parameters.AddWithValue("@ShortContents", txtShortContents.Text.Trim());
            cmd.Parameters.AddWithValue("@ContentImage", lblMainImagePath.Text);
            cmd.Parameters.AddWithValue("@BannerImage", "");
            n=cmd.ExecuteNonQuery();
            obj.CloseConnection();            
            if (n==1)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "set", "alert('Save Successfully...');", true);
            }

            //Server.Transfer("Menu.aspx");
        }

        protected void cmbMenu_SelectedIndexChanged(object sender, EventArgs e)
        {
            dt.Clear();
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            dt = obj.getDataTable(@"SELECT * from tbl_MainMenu 
                    where Menu = '" + 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]["SubHeading"].ToString() != null)
                    txtSubHeading.Text = dt.Rows[0]["SubHeading"].ToString();

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

TechEthical Mini WebShell Version 1.0, Coded By The_M@T3