protected void Btn_Login_Click1(object sender, EventArgs e)
        {
            string        strConnection = ConfigurationManager.ConnectionStrings["TAMConnectionString"].ConnectionString;
            SqlConnection sqlcon        = new SqlConnection(strConnection);

            if (sqlcon.State == ConnectionState.Closed)
            {
                sqlcon.Open();
            }
            try
            {
                string     option      = DropDownListOption.SelectedValue;
                string     Id          = User_Login.Text;
                encrypt    encpass     = new encrypt();
                string     key         = "sblw-3hn8-sqoy19";
                string     encryptpass = encpass.PassEncrypt(User_Password.Text, key);
                SqlCommand sqlcmd      = new SqlCommand("SpLoginCheck", sqlcon);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.AddWithValue("@LoginID", Id);
                sqlcmd.Parameters.AddWithValue("@Password", encryptpass);
                sqlcmd.Parameters.AddWithValue("@Option", option);
                SqlDataAdapter da = new SqlDataAdapter(sqlcmd);

                DataSet ds = new DataSet();



                int results = da.Fill(ds, "LoginID");
                if ((results == 1) && (option == "CargoOwner"))
                {
                    sqlcon.Close();
                    Session["Logged"] = User_Login.Text;
                    Session["Type"]   = "CargoOwner";
                    Response.Redirect("/Cargo/CargoHome.aspx");
                    //  Server.Transfer("/Cargo/CargoHome.aspx");
                }
                else if ((results == 1) && (option == "Driver"))
                {
                    sqlcon.Close();
                    Session["Logged"] = User_Login.Text;
                    Session["Type"]   = "Driver";
                    Server.Transfer("/Driver/DriverPage.aspx");
                    //Response.Redirect("/Driver/DriverHome.aspx");
                }
                else
                {
                    sqlcon.Close();
                    //Response.Redirect("~/Index.aspx");
                    // Page.ClientScript.RegisterStartupScript(this.GetType(), "LoginError", "LoginError();", true);
                }
            }
            catch (Exception here)
            {
                Console.WriteLine(here);
            }
        }
Ejemplo n.º 2
0
        protected void AdminButton_Click(object sender, EventArgs e)
        {
            string        strConnection = ConfigurationManager.ConnectionStrings["TAMConnectionString"].ConnectionString;
            SqlConnection sqlcon        = new SqlConnection(strConnection);

            if (sqlcon.State == ConnectionState.Closed)
            {
                sqlcon.Open();
            }
            try
            {
                string     option      = "Administrator";
                string     LoginID     = Request.Form["username"];
                string     password    = Request.Form["password"];
                encrypt    encpass     = new encrypt();
                string     key         = "sblw-3hn8-sqoy19";
                string     encryptpass = encpass.PassEncrypt(password, key);
                SqlCommand sqlcmd      = new SqlCommand("SpLoginCheck", sqlcon);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.AddWithValue("@LoginID", LoginID);
                sqlcmd.Parameters.AddWithValue("@Password", encryptpass);
                sqlcmd.Parameters.AddWithValue("@Option", option);
                SqlDataAdapter da = new SqlDataAdapter(sqlcmd);

                DataSet ds = new DataSet();



                int results = da.Fill(ds, "LoginID");
                if (results == 1)
                {
                    Session["Logged"] = "Administrator";
                    Session["Type"]   = "Administrator";
                    sqlcon.Close();
                    Response.Redirect("/Admin/AdminHome.aspx");
                    //  Server.Transfer("/Cargo/CargoHome.aspx");
                }

                else
                {
                    sqlcon.Close();
                    Response.Redirect("~/Administrator.aspx");
                }



                // ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowPopup();", true);
                // this.lblMessage.Text = "Your Registration is done successfully. Our team will contact you shotly";
                //Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('FiveDot File uploaded successfully'); alert('TwoDot File uploaded successfully');", true);
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee);
            }
        }
        public string CallFromJS()
        {
            SqlConnection sqlcon = new SqlConnection(strConnection);

            try
            {
                string passwd1   = password.Text;
                string passwd2   = confirm_password.Text;
                string mobile    = mobile_no.Text;
                string homephone = telephone_no.Text;
                if ((passwd1 != passwd2))
                {
                    return("2");
                }


                encrypt encpass = new encrypt();

                string firstname  = first_name.Text;
                string middlename = middle_name.Text;
                string lastname   = last_name.Text;

                string email   = email_id.Text;
                string address = full_address.Text;
                string ID      = login_id.Text;
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }

                SqlCommand sqlcmd = new SqlCommand("SpCargoOwnerIdPassCheck", sqlcon);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.AddWithValue("@LoginID", ID);

                SqlDataReader logusers;
                logusers = sqlcmd.ExecuteReader();

                //  string temp = logusers["temp"].ToString();
                if (logusers.HasRows)
                {
                    sqlcon.Close();
                    return("1");
                }
                if (email_id.Text == "")
                {
                    sqlcon.Close();
                    return("3");
                }

                string     key         = "sblw-3hn8-sqoy19";
                string     encryptpass = encpass.PassEncrypt(password.Text, key);
                SqlCommand sqlcmd2     = new SqlCommand("SpCargoOwnerIns", sqlcon);
                sqlcmd2.CommandType = CommandType.StoredProcedure;
                sqlcmd2.Parameters.AddWithValue("@FirstName", firstname);
                sqlcmd2.Parameters.AddWithValue("@MiddleName", middlename);
                sqlcmd2.Parameters.AddWithValue("@LastName", lastname);
                sqlcmd2.Parameters.AddWithValue("@Mobile", mobile);
                sqlcmd2.Parameters.AddWithValue("@Phone", homephone);
                sqlcmd2.Parameters.AddWithValue("@Email", email);
                sqlcmd2.Parameters.AddWithValue("@Address", address);
                sqlcmd2.Parameters.AddWithValue("@LoginID", ID);
                sqlcmd2.Parameters.AddWithValue("@password", encryptpass);

                sqlcmd2.ExecuteNonQuery();
                sqlcon.Close();
                return("0");



                // ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowPopup();", true);
                // this.lblMessage.Text = "Your Registration is done successfully. Our team will contact you shotly";
                //Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('FiveDot File uploaded successfully'); alert('TwoDot File uploaded successfully');", true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            return(null);
        }