TechEthical CEHP

Current Path : G:/PleskVhosts/megamind.net.in/careercentre360.com/admin/
Upload File :
Current File : G:/PleskVhosts/megamind.net.in/careercentre360.com/admin/StudiesContents.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 StudiesContents : 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.   
                getcourse();
            }


        }

        public void getcourse()
        {
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            string vString = "";

            vString = "Select  ID , NAME from tbl_Courses";

            dt = obj.getDataTable(vString);
            cmbcourses.DataSource = null;
            cmbcourses.DataSource = dt;
            cmbcourses.DataTextField = "NAME";
            cmbcourses.DataValueField = "ID";
            cmbcourses.DataBind();
            cmbcourses.Items.Insert(0, new ListItem("Select","0"));
            obj.CloseConnection();
        }


       
        public void getsubject()
        {
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            string vString = "";

            vString = "Select  ID , NAME from tbl_Subject where course_ID='" + cmbcourses.SelectedValue + "' ";

            dt = obj.getDataTable(vString);
            cmbSubject.DataSource = null;
            cmbSubject.DataSource = dt;
            cmbSubject.DataTextField = "NAME";
            cmbSubject.DataValueField = "ID";
            cmbSubject.DataBind();
            cmbSubject.Items.Insert(0, "");
            obj.CloseConnection();
        }

        public void getUnit()
        {
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            string vString = "";

            vString = "Select  ID , NAME from tbl_Unit where Subject_ID='"+cmbSubject.SelectedValue +"'";

            dt = obj.getDataTable(vString);
            cmbUnit.DataSource = null;
            cmbUnit.DataSource = dt;
            cmbUnit.DataTextField = "NAME";
            cmbUnit.DataValueField = "ID";
            cmbUnit.DataBind();
            cmbUnit.Items.Insert(0, "");
            obj.CloseConnection();
        }

        public void getTopic()
        {
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            string vString = "";

            vString = "Select  ID , NAME from tbl_Topics where Unit_ID='" + cmbUnit.SelectedValue + "'";

            dt = obj.getDataTable(vString);
            cmbTopic.DataSource = null;
            cmbTopic.DataSource = dt;
            cmbTopic.DataTextField = "NAME";
            cmbTopic.DataValueField = "ID";
            cmbTopic.DataBind();
            cmbTopic.Items.Insert(0, "");
            obj.CloseConnection();
        }





       // public void 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 butSubmit_Click(object sender, EventArgs e)
        {
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            int n = 0;
            SqlCommand cmd = new SqlCommand("SP_SaveContenttable", obj.conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Course", cmbcourses.SelectedValue);
            cmd.Parameters.AddWithValue("@Subject", cmbSubject.SelectedValue);
            cmd.Parameters.AddWithValue("@Unit", cmbUnit.SelectedValue);
            cmd.Parameters.AddWithValue("@Topic", cmbTopic.SelectedValue);
            cmd.Parameters.AddWithValue("@Title", txtTitle.Text.Trim());
            cmd.Parameters.AddWithValue("@videoLink", txtvideolink.Text);
            cmd.Parameters.AddWithValue("@ShortContents", txtshortcontant.Text);
            cmd.Parameters.AddWithValue("@FullContents", txtFullContents.Text);
            cmd.Parameters.AddWithValue("@Download", FileUpload1.FileName);


            n = cmd.ExecuteNonQuery();

            FileUpload1.SaveAs(Server.MapPath("/OnlineStudy/Notes/") + FileUpload1.FileName);

            ScriptManager.RegisterStartupScript(this, GetType(), "set", "alert('Submit Successfully');", true);
            obj.CloseConnection();
        }

        protected void cmbcourses_SelectedIndexChanged(object sender, EventArgs e)
        {
            getsubject();
        }

        protected void cmbSubject_SelectedIndexChanged(object sender, EventArgs e)
        {
            getUnit();
        }

        protected void cmbUnit_SelectedIndexChanged(object sender, EventArgs e)
        {
            getTopic();
        }

        protected void cmbTopic_SelectedIndexChanged(object sender, EventArgs e)
        {
            connection_sql obj = new connection_sql();
            obj.MakeConnection();

            
                SqlCommand cmd = new SqlCommand("Select * FROM tbl_Contanttable WHERE Topic='" + cmbTopic.SelectedValue + "' ", obj.conn);
            
            //SqlCommand cmd = new SqlCommand("SP_getContent", obj.conn);
            //cmd.Parameters.AddWithValue("@Topic",cmbTopic.SelectedValue);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            obj.CloseConnection();
            if (dt.Rows.Count >0)
            {
                txtTitle.Text = dt.Rows[0]["Title"].ToString();
                txtvideolink.Text = dt.Rows[0]["videolink"].ToString();
                txtshortcontant.Text = dt.Rows[0]["ShortContents"].ToString();
                txtFullContents.Text = dt.Rows[0]["FullContents"].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("@Courses", cmbcourses.Text.Trim());
        //            cmd.Parameters.AddWithValue("@Subject", cmbSubject.Text.Trim());
        //            cmd.Parameters.AddWithValue("@Unit", cmbUnit.Text.Trim());
        //            cmd.Parameters.AddWithValue("@Topic", cmbTopic.Text.Trim());
        //            cmd.Parameters.AddWithValue("@Title", TextBox1.Text);
        //            cmd.Parameters.AddWithValue("@Video link", txtvideolink.Text);
        //            cmd.Parameters.AddWithValue("@Short Contant", TextBox2.Text);
        //            cmd.Parameters.AddWithValue("@Full Contant", txtFullContents.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]["Courses"].ToString() != null)
        //                    cmbcourses.Text =dt.Rows[0]["Courses"].ToString();

        //                if (dt.Rows[0]["Subject"].ToString() != null)
        //                    cmbSubject.Text =dt.Rows[0]["Subject"].ToString();

        //                if (dt.Rows[0]["Unit"].ToString() != null)
        //                    cmbUnit.Text =dt.Rows[0]["Unit"].ToString();

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

         //                 if (dt.Rows[0]["Video Link"].ToString() != null)
        //                    txtFullContents.Text =dt.Rows[0]["Topic"].ToString();


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

         //                 if (dt.Rows[0]["S"].ToString() != null)
        //                    txtFullContents.Text =dt.Rows[0]["Topic"].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