Beispiel #1
0
        //Function To Insert Values And Registration Details Of New Customer
        protected void RegisterDetails()
        {
            try
            {
                con.Open();
                string       custemail          = TextBoxEmail.Text;
                string       checkexistingemail = "select CustEmail from registrationdetails where CustEmail like '" + custemail + "';";
                MySqlCommand cm = new MySqlCommand(checkexistingemail, con);

                if (cm.ExecuteScalar() == null)
                {
                    //inserting into registrationdetails table
                    string       pass = PasswordEncrypt.EncryptText(TextBoxPassword.Text);
                    MySqlCommand cmd  = new MySqlCommand("insert into registrationdetails (CustUserName,CustEmail,CustPassword,CustAddress,CustPhone,CustCountry) values('" + TextBoxUserName.Text + "','" +
                                                         custemail + "','" + pass + "','" + TextBoxAddress.Text + "','" + TextBoxPhone.Text + "','" + DropDownListCountry.Text + "')", con);
                    cmd.ExecuteNonQuery();
                    string       getCustID = "select CustUserID from registrationdetails where CustEmail like '" + custemail + "';";
                    MySqlCommand cmd1      = new MySqlCommand(getCustID, con);
                    Int32        custID    = (Int32)cmd1.ExecuteScalar();

                    //inserting into vehicledetails table
                    MySqlCommand cmd2 = new MySqlCommand("insert into vehicledetails (VehicleNo,VehicleBrand,VehicleModel,EngineNo,ChassisNo,CustUserID) values('" + TextBoxVehicleNumber.Text + "','" +
                                                         TextBoxVehicleBrand.Text + "','" + TextBoxVehicleModel.Text + "','" + TextBoxVehicleEngineNumber.Text + "','" + TextBoxVehicleChassisNumber.Text + "','" + custID + "')", con);
                    cmd2.ExecuteNonQuery();

                    //get vehicleID
                    string       getVehicleID = "select VehicleID from vehicledetails where VehicleNo like '" + TextBoxVehicleNumber.Text + "';";
                    MySqlCommand cmd3         = new MySqlCommand(getVehicleID, con);
                    Int32        vehicleID    = (Int32)cmd3.ExecuteScalar();

                    //get Employee ID
                    string       getemployee = "select empid from employeedetails where empemail like '" + Session["empname"].ToString() + "';";
                    MySqlCommand cmd4        = new MySqlCommand(getemployee, con);
                    Int32        getEmpID    = (Int32)cmd4.ExecuteScalar();

                    //inserting into jobcarddetails
                    MySqlCommand cmd5 = new MySqlCommand("insert into jobcarddetails (VehicleProblem,ServiceStatus,CustUserID,VehicleID,EmpID) values('" + TextBoxVehicleProblem.Text + "','Pending'," + custID + "," + vehicleID + "," + getEmpID + ");", con);
                    cmd5.ExecuteNonQuery();

                    Label1.Visible = true;
                    Label1.Text    = "Registration Successfull";
                    resetValues();
                }
                else
                {
                    Label1.Visible = true;
                    Label1.Text    = "Cannot Register As Customer Already Exists! Please Choose Existing Customer!!";
                    resetValues();
                }
            }
            catch (Exception e)
            {
                Response.Write(e.ToString());
            }
            finally
            {
                con.Close();
            }
        }
Beispiel #2
0
        public int getLoginFlag(string TextBoxUsername, string TextBoxPassword)
        {
            using (MySqlConnection con = new MySqlConnection("Server='localhost'; Database='aspcrud';User='******';Password='******';SslMode=None"))
            {
                string query      = "select count(1) from registrationdetails where CustEmail=@username and CustPassword=@password";
                string adminquery = "select count(1) from admin where adminemail=@admineml and adminpassword=@adminpass";
                string empquery   = "select count(1) from employeedetails where empemail=@empeml and emppassword=@emppass";
                con.Open();
                //Customer
                MySqlCommand sqlCmd = new MySqlCommand(query, con);
                //Admin
                MySqlCommand adminsqlcmd = new MySqlCommand(adminquery, con);
                //Employee
                MySqlCommand empcmd = new MySqlCommand(empquery, con);
                string       pass   = PasswordEncrypt.EncryptText(TextBoxPassword);
                //Customer
                sqlCmd.Parameters.AddWithValue("@username", TextBoxUsername.Trim());
                sqlCmd.Parameters.AddWithValue("@password", pass.Trim());
                //Admin
                string adminuser = PasswordEncrypt.EncryptText(TextBoxUsername);
                adminsqlcmd.Parameters.AddWithValue("@admineml", adminuser.Trim());
                adminsqlcmd.Parameters.AddWithValue("@adminpass", pass.Trim());
                //Employee
                empcmd.Parameters.AddWithValue("@empeml", TextBoxUsername.Trim());
                empcmd.Parameters.AddWithValue("@emppass", pass.Trim());
                //Customer
                var count = sqlCmd.ExecuteScalar();
                //Admin
                var adminlogcnt = adminsqlcmd.ExecuteScalar();
                //Employee
                var empcount = empcmd.ExecuteScalar();

                if (Convert.ToInt32(adminlogcnt) == 1)
                {
                    return(2);
                }
                else
                if (Convert.ToInt32(empcount) == 1)
                {
                    return(3);
                }
                else
                if (Convert.ToInt32(count) == 1)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        }
Beispiel #3
0
        protected void RegisterEmpDetails()
        {
            con.Open();
            string       emppass = PasswordEncrypt.EncryptText(TextBoxEmpPassword.Text);
            MySqlCommand cmd     = new MySqlCommand("insert into employeedetails (empname,empemail,emppassword,empaddress,empphone) values('" + TextBoxEmpUserName.Text + "','" + TextBoxEmpEmail.Text + "','" +
                                                    emppass + "','" + TextBoxEmpAddress.Text + "'," + TextBoxEmpPhone.Text + ")", con);

            cmd.ExecuteNonQuery();
            con.Close();
            EmpRegisterLabel.Visible = true;
            EmpRegisterLabel.Text    = "Registration Successfull";
            TextBoxEmpUserName.Text  = "";
            TextBoxEmpEmail.Text     = "";
            TextBoxEmpPassword.Text  = "";
            TextBoxEmpAddress.Text   = "";
            TextBoxEmpPhone.Text     = "";
        }
        private void Register()
        {
            MySqlConnection con = new MySqlConnection("Server='localhost'; Database='aspcrud';User='******';Password='******';SslMode=None");

            con.Open();

            string       AdminUserName = "******";
            string       AdminEmail    = PasswordEncrypt.EncryptText("*****@*****.**");
            string       AdminPassword = PasswordEncrypt.EncryptText("Sourabh123!");
            MySqlCommand cmd           = new MySqlCommand("insert into admin (adminname,adminemail,adminpassword) values('" + AdminUserName + "','" +
                                                          AdminEmail + "','" + AdminPassword + "')", con);
            int i = cmd.ExecuteNonQuery();

            con.Close();
            if (i == 1)
            {
                SuccessRegister.Visible = true;
                SuccessRegister.Text    = "Registration Successfull";
            }
        }