Esempio n. 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            encpass enc = new encpass();

            if (txtUsername.Text == "")
            {
                MessageBox.Show("please input user name");
            }
            else if (txtPassword.Text == "")
            {
                MessageBox.Show("please input password");
            }
            else if (txtPassword.Text.Length < 8 || txtPassword.Text.Length > 12)
            {
                MessageBox.Show("password should be <8 and >12");
            }
            else
            {
                String  str = "select * from user_creation where user_name='" + txtUsername.Text + "'";
                DataSet ds  = new DataSet();
                ds = dl.GetDataSet(str);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    String  str1 = "select * from user_creation where password='******'";
                    DataSet ds1  = new DataSet();
                    ds1 = dl.GetDataSet(str1);
                    if (ds1.Tables[0].Rows.Count > 0)
                    {
                        if (ds1.Tables[0].Rows[0]["user_type"].ToString() == "ADMIN")
                        {
                            DataLayer.uname    = txtUsername.Text;
                            menuStrip1.Visible = true;
                            panel2.Visible     = false;


                            //disable mandina enable manpi
                            //panelLogin disab;e
                        }


                        else
                        {
                            MessageBox.Show("invalid password");
                        }
                    }
                    else
                    {
                        MessageBox.Show("invalid password");
                    }
                }
                else
                {
                    MessageBox.Show("invalid user name");
                }
            }
        }
Esempio n. 2
0
        private void btnLogin_Click_2(object sender, EventArgs e)
        {
            encpass enc = new encpass();

            if (txtUsername.Text == "")
            {
                MessageBox.Show("please input user name");
            }
            else if (txtPassword.Text == "")
            {
                MessageBox.Show("please input password");
            }
            else if (txtPassword.Text.Length != 8)
            {
                MessageBox.Show("Password must be of 8 characters only");
            }
            else
            {
                String  str = "select * from user_creation where user_name='" + txtUsername.Text + "'";
                DataSet ds  = new DataSet();
                ds = dl.GetDataSet(str);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    String  str1 = "select * from user_creation where password='******'";
                    DataSet ds1  = new DataSet();
                    ds1 = dl.GetDataSet(str1);
                    if (ds1.Tables[0].Rows.Count > 0)
                    {
                        if (ds1.Tables[0].Rows[0]["user_type"].ToString() == "ADMIN")
                        {
                            DataLayer.uname       = txtUsername.Text;
                            panelleftmain.Visible = true;
                            panelMDI.Visible      = true;
                        }
                        //else if (ds1.Tables[0].Rows[0]["user_type"].ToString() == "USER")
                        //{
                        //    DataLayer.uname = txtUsername.Text;

                        //}
                        else
                        {
                            MessageBox.Show("invalid password");
                        }
                    }
                    else
                    {
                        MessageBox.Show("invalid password");
                    }
                }
                else
                {
                    MessageBox.Show("invalid user name");
                }
            }
        }
Esempio n. 3
0
        private void btnChangepassword_Click(object sender, EventArgs e)
        {
            encpass enc = new encpass();

            if (txtNewpassword.Text == "")
            {
                MessageBox.Show("Please input New Password");
            }
            else if (txtConfirmpassword.Text != txtNewpassword.Text)
            {
                MessageBox.Show("Password does not match");
            }
            else if (txtCurrentpassword.Text == "")
            {
                MessageBox.Show("Please input Current Password");
            }
            else if (txtNewpassword.Text.Length != 8)
            {
                MessageBox.Show("Password must be of 8 characters or digits only");
            }
            else if (txtCurrentpassword.Text.Length != 8)
            {
                MessageBox.Show("Password must be of 8 characters or digits only");
            }
            else
            {
                String  str = "select * from user_creation where user_name='" + DataLayer.uname.ToString() + "' and password='******'";
                DataSet ds  = new DataSet();
                ds = dl.GetDataSet(str);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (txtNewpassword.Text == txtConfirmpassword.Text)
                    {
                        str = "update user_creation set password='******' where user_name='" + DataLayer.uname.ToString() + "'";
                        dl.DmlCmd(str);
                        MessageBox.Show("password changed successful");
                    }
                    else
                    {
                        MessageBox.Show("password does not match");
                    }
                }
                else
                {
                    MessageBox.Show("invalid password");
                }
            }
        }
Esempio n. 4
0
        private void btnGetpassword_Click(object sender, EventArgs e)
        {
            encpass enc = new encpass();

            String  str = "select * from user_creation where user_name='" + txtUsername.Text + "'";
            DataSet ds  = new DataSet();

            ds = dl.GetDataSet(str);
            if (ds.Tables[0].Rows.Count > 0)
            {
                String email = ds.Tables[0].Rows[0]["email"].ToString();
                Random r     = new Random();
                String s     = r.NextDouble().ToString();
                s = s.Substring(3, 8);
                SmtpClient client = new SmtpClient("smtp.gmail.com");
                client.Port = 587;

                client.EnableSsl             = true;
                client.Timeout               = 100000;
                client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Credentials           = new NetworkCredential("*****@*****.**", "achhu9880055037");
                MailMessage msg = new MailMessage();
                msg.To.Add(email);
                msg.From    = new MailAddress(email);
                msg.Subject = "forgot password";
                msg.Body    = "your new password is='" + s + "'";
                client.Send(msg);
                str = "update user_creation set password='******' where user_name='" + txtUsername.Text + "'";
                dl.DmlCmd(str);
            }
            else
            {
                MessageBox.Show("invalid user");
            }
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            encpass enc = new encpass();

            if (verification(txtEmail.Text.Trim()))
            {
                if (txtUsername.Text == "")
                {
                    MessageBox.Show("please input username");
                }
                else if (txtPassword.Text == "")
                {
                    MessageBox.Show("please input password");
                }
                else if (cmbUsertype.Text == "")
                {
                    MessageBox.Show("please select usertype");
                }
                else if (txtEmail.Text == "")
                {
                    MessageBox.Show("please input email");
                }
                else if (txtConfirmpassword.Text != txtPassword.Text)
                {
                    MessageBox.Show("password does not match");
                }
                else if (txtPno.Text == "")
                {
                    MessageBox.Show("please input phone number");
                }
                else if (txtPassword.Text.Length != 8)
                {
                    MessageBox.Show("Password must be of 8 characters or digits only");
                }
                else if (txtPno.Text.Length < 10 || txtPno.Text.Length > 10)
                {
                    MessageBox.Show("invalid phoneno");
                }
                else
                {
                    String  str1 = "select * from  user_creation where user_name='" + txtUsername.Text + "'";
                    DataSet ds   = new DataSet();
                    ds = dl.GetDataSet(str1);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        MessageBox.Show("username already exist");
                    }
                    else
                    {
                        String str = "insert into user_creation( user_name, password, user_type, email, phone)values('" + txtUsername.Text + "','" + enc.EncryptConnectionString(txtPassword.Text) + "','" + cmbUsertype.Text + "','" + txtEmail.Text + "','" + txtPno.Text + "')";
                        dl.DmlCmd(str);
                        fillgrid();
                        MessageBox.Show("record inserted successfully");
                    }
                }
            }
            else
            {
                MessageBox.Show("INVALID EMAIL");
            }
        }