Пример #1
0
        protected void cpwdbtn_Click(object sender, EventArgs e)
        {
            string OldP = oldpwd.Text, NewP = newpwd.Text, NewP1 = newpwdcon.Text, DP;

            if (OldP == "" || NewP == "" || NewP1 == "")
            {
                Main.Reg(Page, "showError(20)");
            }
            else
            {
                using (SqlConnection sql = new SqlConnection(db))
                {
                    string     Query = "Select Password From Accounts where (Username='******')";
                    SqlCommand cmd   = new SqlCommand();
                    cmd.CommandText = Query;
                    cmd.Connection  = sql;
                    SqlDataAdapter da = new SqlDataAdapter();
                    da.SelectCommand = cmd;
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    DP = sh.dekryptPassword(ds.Tables[0].Rows[0]["Password"].ToString());
                    sql.Close();
                }
                if (OldP == DP)
                {
                    if (NewP == NewP1)
                    {
                        if (OldP != NewP)
                        {
                            string update = "Update Accounts set Password='******' where Username='******'";

                            using (SqlConnection sql1 = new SqlConnection(db))
                            {
                                SqlCommand cmd1 = new SqlCommand();
                                cmd1.CommandText = update;
                                cmd1.Connection  = sql1;
                                sql1.Open();
                                cmd1.ExecuteNonQuery();
                                //sql1.Close();
                            }
                            UpdateLastChanged();

                            // TODO Success
                        }
                        else
                        {
                            Main.Reg(Page, "showError(23)");
                        }
                    }
                    else
                    {
                        Main.Reg(Page, "showError(22)");
                    }
                }
                else
                {
                    Main.Reg(Page, "showError(21)");
                }
            }
        }