TechEthical CEHP

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

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

namespace Directory.admin
{
    public partial class ViewFreeRegistration : System.Web.UI.Page
    {
        public System.Data.DataTable dt = new System.Data.DataTable();
        public System.Data.SqlClient.SqlDataAdapter SqlAdapter = new SqlDataAdapter();
        public DataTable dtCourse = new DataTable();
        public DataTable dtEducation = new DataTable();
        public DataTable dtState = new DataTable();
        public DataTable dtDistrict = new DataTable(); 
        
//        protected void Page_Load(object sender, EventArgs e)
//        {
//            connection_sql obj = new connection_sql();
//            obj.MakeConnection();


////            DataSet dd = obj.getDataSet(@"SELECT  ROW_NUMBER() OVER (ORDER BY Id) AS Sno, Name, Status
////                FROM [tblCategory] ");

//            if (!IsPostBack)
//            {
//                if (Session["Loginxtr"].ToString() != "1254lkjhhfdgftfrdgf")
//                {
//                    Response.Redirect("login.aspx");
//                }

//                dt.Clear();
                
//                obj.MakeConnection();
//                dt = obj.getDataTable(@"SELECT TOP 500 ROW_NUMBER() OVER (ORDER BY ID Desc) AS 'Sr No', "
//                    + " Convert(VARCHAR, DATES,106) AS Dates, Name, PhoneNumber as Mobile, Course, Subject,  EmailID, qry as Comment " 
//                    + " FROM [tbl_qryForm] order by id desc");

//                //GridView1.DataSource = dt;
//                //GridView1.DataBind();

//            }
//        }

        protected void Page_Load(object sender, EventArgs e)
        {
             if (!IsPostBack)
                {
                    //DataTable dt = new DataTable();
                    //connection_sql obj = new connection_sql();
                    //obj.MakeConnection();
                    //dtCourse = obj.getDataTable("select name from tbl_Courses order by Name");
                    
                    //dtState = obj.getDataTable("select id, name from tbl_State order by name");
                    //dtDistrict = obj.getDataTable("select name from tbl_District order by Name");
                    
                    //dtEducation = obj.getDataTable("select name from tbl_Education order by Name");
                    
                    //obj.CloseConnection();

                 
                    GridFill();
                }               
        }

        protected void GridFill()
        {
            connection_sql obj = new connection_sql();
            obj.MakeConnection();

            DataSet ds = new DataSet();
            ds = obj.getDataSet("SELECT ROW_NUMBER() OVER (ORDER BY ID Desc) AS 'SRN', "
                + " [ID], [Course1], [Course2], Batch, [Name], [Gender], [Mobile1], [Mobile2] " 
                + " ,[Email], [States], [District], [Locality], [OurStudent], [RollNo] "
                + " ,[CourseYear], [Education], [Remark], convert(varchar, AutoDate, 106) as AutoDate"
                + " ,VerifiedMobile, Password, BlackList, OnlineTest, OnlineNotes, OnlineVideo "
                + " ,OfflineTestResult, HomeTest, CurrentAffairs, Status "
                + " FROM [dbo].[tbl_FreeRegistration] order by id desc" );

            int count = ds.Tables[0].Rows.Count;
            obj.CloseConnection();
 
            if (ds.Tables[0].Rows.Count > 0)
            {
                gridView.DataSource = ds;
                gridView.DataBind();
            }
            else
            {
                ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
                gridView.DataSource = ds;
                gridView.DataBind();
                int columncount = gridView.Rows[0].Cells.Count;
                lblmsg.Text = "No data found !!!";
            }
        }

        protected void gridView_RowEditing(object sender, GridViewEditEventArgs e)
        {
            gridView.EditIndex = e.NewEditIndex;
            GridFill();
        }

        protected void gridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string UpdateID = gridView.DataKeys[e.RowIndex].Values["ID"].ToString();
            TextBox txtName = (TextBox)gridView.Rows[e.RowIndex].FindControl("txtName");
            DropDownList cmbCourse1 = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbCourse1");
            DropDownList cmbCourse2 = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbCourse2");

            TextBox txtBatch = (TextBox)gridView.Rows[e.RowIndex].FindControl("txtBatch");

            TextBox txtMobile1 = (TextBox)gridView.Rows[e.RowIndex].FindControl("txtMobile1");           
            TextBox txtMobile2 = (TextBox)gridView.Rows[e.RowIndex].FindControl("txtMobile2");
            DropDownList cmbGender = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbGender");
            TextBox txtEmail = (TextBox)gridView.Rows[e.RowIndex].FindControl("txtEmail");
            DropDownList cmbOurStudent = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbOurStudent");
            TextBox txtRollNo = (TextBox)gridView.Rows[e.RowIndex].FindControl("txtRollNo");
            TextBox txtCourseYear = (TextBox)gridView.Rows[e.RowIndex].FindControl("txtCourseYear");
            DropDownList cmbState = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbStates");
            DropDownList cmbDistrict = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbDistrict");
            DropDownList cmbEducation = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbEducation");
            TextBox txtLocality = (TextBox)gridView.Rows[e.RowIndex].FindControl("txtLocality");
            TextBox txtRemark = (TextBox)gridView.Rows[e.RowIndex].FindControl("txtRemark");

            TextBox txtPassword = (TextBox)gridView.Rows[e.RowIndex].FindControl("txtPassword");
            DropDownList cmbVerifiedMobile = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbVerifiedMobile");
            DropDownList cmbBlackList = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbBlackList");
            DropDownList cmbOnlineTest = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbOnlineTest");
            DropDownList cmbOnlineNotes = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbOnlineNotes");
            DropDownList cmbOnlineVideo = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbOnlineVideo");
            DropDownList cmbOfflineTestResult = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbOfflineTestResult");
            DropDownList cmbHomeTest = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbHomeTest");
            DropDownList cmbCurrentAffairs = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbCurrentAffairs");
            DropDownList cmbStatus = (DropDownList)gridView.Rows[e.RowIndex].FindControl("cmbStatus");
           
                      
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            SqlCommand cmd = new SqlCommand("SP_Registration1", obj.conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@ID", UpdateID);
            cmd.Parameters.AddWithValue("@Course1", cmbCourse1.Text);
            cmd.Parameters.AddWithValue("@Course2", cmbCourse2.Text);
            cmd.Parameters.AddWithValue("@Batch", txtBatch.Text);
            cmd.Parameters.AddWithValue("@Name", txtName.Text);
            cmd.Parameters.AddWithValue("@Gender", cmbGender.Text);
            cmd.Parameters.AddWithValue("@Mobile1", txtMobile1.Text);
            cmd.Parameters.AddWithValue("@Mobile2", txtMobile2.Text);
            cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
            cmd.Parameters.AddWithValue("@States", cmbState.Text);
            cmd.Parameters.AddWithValue("@District", cmbDistrict.Text);
            cmd.Parameters.AddWithValue("@Locality", txtLocality.Text);
            cmd.Parameters.AddWithValue("@OurStudent", cmbOurStudent.Text);
            cmd.Parameters.AddWithValue("@RollNo", txtRollNo.Text);
            cmd.Parameters.AddWithValue("@CourseYear", txtCourseYear.Text);
            cmd.Parameters.AddWithValue("@Education", cmbEducation.Text);
            cmd.Parameters.AddWithValue("@Remark", txtRemark.Text);
            cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
            //cmd.Parameters.AddWithValue("@AutoDate", DateTime.Now);
            
            cmd.Parameters.AddWithValue("@VerifiedMobile", cmbVerifiedMobile.Text.Trim());
            cmd.Parameters.AddWithValue("@BlackList", cmbBlackList.Text);
            cmd.Parameters.AddWithValue("@OnlineTest", cmbOnlineTest.Text);
            cmd.Parameters.AddWithValue("@OnlineNotes", cmbOnlineNotes.Text);
            cmd.Parameters.AddWithValue("@OnlineVideo", cmbOnlineVideo.Text);
            cmd.Parameters.AddWithValue("@OfflineTestResult", cmbOfflineTestResult.Text);
            cmd.Parameters.AddWithValue("@HomeTest", cmbHomeTest.Text);
            cmd.Parameters.AddWithValue("@CurrentAffairs", cmbCurrentAffairs.Text);
            cmd.Parameters.AddWithValue("@Status", cmbStatus.Text);
            cmd.ExecuteNonQuery();

            obj.CloseConnection();

            lblmsg.BackColor = System.Drawing.Color.Blue;
            lblmsg.ForeColor = System.Drawing.Color.White;
            lblmsg.Text = "'" + txtName.Text + "'  Updated successfully........    ";
            gridView.EditIndex = -1;
            GridFill();
        }

        protected void gridView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            gridView.EditIndex = -1;
            GridFill();
        }

        protected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string ID = gridView.DataKeys[e.RowIndex].Values["ID"].ToString();
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            
            int result=obj.ExcuteCommand("delete from tbl_FreeRegistration where id=" + ID);
           
            obj.CloseConnection();
            if (result == 1)
            {
                GridFill();
                lblmsg.BackColor = System.Drawing.Color.Red;
                lblmsg.ForeColor = System.Drawing.Color.White;
                lblmsg.Text = ID + "      Deleted successfully.......    ";
            }
        }

        public DataTable BindCource()
        {
            DataTable dt = new DataTable();
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            dt = obj.getDataTable("select name from vw_Course  order by Name");
            obj.CloseConnection();
            return dt;
        }

        public DataTable BindState()
        {
            DataTable dt = new DataTable();
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            dt = obj.getDataTable("select name from tbl_State order by Name");
            obj.CloseConnection();
            return dt;
        }

        public DataTable BindDistrict()
        {
            DataTable dt = new DataTable();
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            dt = obj.getDataTable("select name from tbl_District order by Name");
            obj.CloseConnection();
            return dt;
        }


        public DataTable BindEducation()
        {
            DataTable dt = new DataTable();
            connection_sql obj = new connection_sql();
            obj.MakeConnection();
            dt = obj.getDataTable("select name from tbl_Education order by Name");
            obj.CloseConnection();
            return dt;
        }

        protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //   if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState == DataControlRowState.Edit)


            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string ID = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "ID"));
                Button lnkbtnresult = (Button)e.Row.FindControl("ButtonDelete");

                // DropDownList lnkbtnresult1 = (DropDownList)e.Row.FindControl("cmbCourse2");

                if (lnkbtnresult != null)
                {
                    lnkbtnresult.Attributes.Add("onclick", "javascript:return deleteConfirm('" + ID + "')");
                }

                    ////╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│

                    //DropDownList cmbCourse1 = (DropDownList)e.Row.FindControl("cmbCourse1");
                    //cmbCourse1.DataSource = dtCourse;
                    //cmbCourse1.DataTextField = "Name";
                    //cmbCourse1.DataValueField = "Name";
                    //cmbCourse1.DataBind();

                    ////Add Default Item in the DropDownList
                    //cmbCourse1.Items.Insert(0, new ListItem(""));

                    ////Select the Course2 of Customer in DropDownList
                    //string lblCourse1 = (e.Row.FindControl("lblCourse1") as Label).Text;
                    //cmbCourse1.Items.FindByValue(lblCourse1).Selected = true;
                    ////╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│

                    //DropDownList cmbCourse2 = (e.Row.FindControl("cmbCourse2") as DropDownList);
                    //cmbCourse2.DataSource = dtCourse;
                    //cmbCourse2.DataTextField = "Name";
                    //cmbCourse2.DataValueField = "Name";
                    //cmbCourse2.DataBind();

                    ////Add Default Item in the DropDownList
                    //cmbCourse2.Items.Insert(0, new ListItem(""));

                    ////Select the Course2 of Customer in DropDownList
                    //string lblCourse2 = (e.Row.FindControl("lblCourse2") as Label).Text;
                    //cmbCourse2.Items.FindByValue(lblCourse2).Selected = true;
                    ////╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│

                    //DropDownList cmbState = (e.Row.FindControl("cmbStates") as DropDownList);

                    //cmbState.DataSource = dtState;
                    //cmbState.DataTextField = "Name";
                    //cmbState.DataValueField = "Name";
                    //cmbState.DataBind();

                    ////Add Default Item in the DropDownList
                    //cmbState.Items.Insert(0, new ListItem(""));

                    ////Select the State of Customer in DropDownList
                    //string lblState = (e.Row.FindControl("lblStates") as Label).Text;
                    //cmbState.Items.FindByValue(lblState).Selected = true;
                    ////╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│

                    //DropDownList cmbDistrict = (e.Row.FindControl("cmbDistrict") as DropDownList);
                    //cmbDistrict.DataSource = dtState;
                    //cmbDistrict.DataTextField = "Name";
                    //cmbDistrict.DataValueField = "Name";
                    //cmbDistrict.DataBind();

                    ////Add Default Item in the DropDownList
                    //cmbDistrict.Items.Insert(0, new ListItem(""));

                    ////Select the District of Customer in DropDownList
                    //string lblDistrict = (e.Row.FindControl("lblDistrict") as Label).Text;
                    //cmbDistrict.Items.FindByValue(lblDistrict).Selected = true;
                    ////╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│


                    //DropDownList cmbEducation = (e.Row.FindControl("cmbEducation") as DropDownList);
                    //cmbEducation.DataSource = dtEducation;
                    //cmbEducation.DataTextField = "Name";
                    //cmbEducation.DataValueField = "Name";
                    //cmbEducation.DataBind();

                    ////Add Default Item in the DropDownList
                    //cmbEducation.Items.Insert(0, new ListItem(""));

                    ////Select the Country of Customer in DropDownList
                    //string lblEducation = (e.Row.FindControl("lblEducation") as Label).Text;
                    //cmbEducation.Items.FindByValue(lblEducation).Selected = true;
                
                //╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│╡│                
            }
        }


        protected void gridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EDT")
            {
                Response.Redirect("EditFreeRegistration.aspx?Reg=" + e.CommandArgument);
            }

            if (e.CommandName.Equals("AddNew"))
            {
                //Ad new value

                int Result = 0;

                if (Result == 1)
                {
                    GridFill();
                    lblmsg.BackColor = System.Drawing.Color.Green;
                    lblmsg.ForeColor = System.Drawing.Color.White;
                    lblmsg.Text = "  Added successfully......    ";
                }
                else
                {
                    lblmsg.BackColor = System.Drawing.Color.Red;
                    lblmsg.ForeColor = System.Drawing.Color.White;
                    lblmsg.Text = " Error while adding row.....";
                }
            }

        }

    }
}

TechEthical Mini WebShell Version 1.0, Coded By The_M@T3