Exemplo n.º 1
0
        //txbEmail_TextChanged
        private void txbEmail_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (flag_zero_load == true)
            {
                try
                {
                    EC_tb_User ec_tb_user = GetUser();
                    HandleControl();
                    imgEmail.Visibility = System.Windows.Visibility.Visible;

                    if (bus_tb_user.UpdateUser(ec_tb_user, StaticClass.GeneralClass.flag_database_type_general) == 1)
                    {
                        imgEmail.Source = ok_bitmapimage;
                    }
                    else
                    {
                        imgEmail.Source = failed_bitmapimage;
                    }
                }
                catch (Exception ex)
                {
                    Pages.Notification page = new Pages.Notification();
                    page.tblNotification.Text = ex.Message;
                    page.ShowDialog();
                }
            }
        }
Exemplo n.º 2
0
        //InSertAllUser
        private int InSertAllUser(DataTable tb_user)
        {
            int result = 0;

            foreach (DataRow datarow in tb_user.Rows)
            {
                if (datarow[0].ToString() != "")
                {
                    EC_tb_User ec_tb_user = new EC_tb_User();
                    ec_tb_user.ID       = Convert.ToInt32(datarow[0].ToString());
                    ec_tb_user.Name     = datarow[1].ToString();
                    ec_tb_user.Email    = datarow[2].ToString();
                    ec_tb_user.Address  = datarow[3].ToString();
                    ec_tb_user.Password = datarow[4].ToString();
                    ec_tb_user.Question = datarow[5].ToString();
                    ec_tb_user.Answer   = datarow[6].ToString();

                    if (bus_tb_user.InsertUser(ec_tb_user, StaticClass.GeneralClass.flag_database_type_general) == 1)
                    {
                        result++;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        //GetUser
        private EC_tb_User GetUser()
        {
            EC_tb_User ec_tb_user = new EC_tb_User();

            ec_tb_user.ID       = Convert.ToInt32(tblID.Text.Trim().ToString());
            ec_tb_user.Name     = StaticClass.GeneralClass.HandlingSpecialCharacter(tblUserName.Text.Trim().ToString());
            ec_tb_user.Email    = StaticClass.GeneralClass.HandlingSpecialCharacter(txbEmail.Text.Trim().ToString());
            ec_tb_user.Address  = StaticClass.GeneralClass.HandlingSpecialCharacter(txbAddress.Text.Trim().ToString());
            ec_tb_user.Password = StaticClass.GeneralClass.HandlingSpecialCharacter(StaticClass.GeneralClass.password_user_general);
            ec_tb_user.Question = StaticClass.GeneralClass.HandlingSpecialCharacter(txbQuestion.Text.Trim().ToLower());
            ec_tb_user.Answer   = StaticClass.GeneralClass.HandlingSpecialCharacter(txbAnswer.Text.Trim().ToLower());

            return(ec_tb_user);
        }
Exemplo n.º 4
0
        //btnChange_Click
        private void btnChange_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (pwbNewPassword.Password.Trim() == "")
                {
                    tblNotification.Text = FindResource("new_password_null").ToString();
                    pwbNewPassword.Focus();
                    return;
                }

                if (pwbNewPassword.Password.Trim().Length < 3)
                {
                    tblNotification.Text = FindResource("password_short").ToString();
                    pwbNewPassword.Focus();
                    return;
                }

                if (pwbConfirmPassword.Password.Trim() == "")
                {
                    tblNotification.Text = FindResource("confirm_password_null").ToString();
                    pwbConfirmPassword.Focus();
                    return;
                }

                if (pwbNewPassword.Password.Trim() != pwbConfirmPassword.Password.Trim().ToString())
                {
                    tblNotification.Text = FindResource("new_password_confirm_password_incorrect").ToString();
                    pwbNewPassword.Focus();
                    return;
                }

                else
                {
                    EC_tb_User ec_tb_user = new EC_tb_User();
                    ec_tb_user.ID       = 1;
                    ec_tb_user.Password = StaticClass.GeneralClass.MD5Hash(pwbNewPassword.Password.Trim());
                    if (bus_tb_user.UpdatePasswordUser(ec_tb_user, StaticClass.GeneralClass.flag_database_type_general) == 1)
                    {
                        BBCodeBlock bbcodeblock = new BBCodeBlock();
                        bbcodeblock.LinkNavigator.Navigate(new Uri(@"/Pages/Home/Login.xaml", UriKind.Relative), this);
                    }
                }
            }
            catch (Exception ex)
            {
                tblNotification.Text = ex.Message;
            }
        }
Exemplo n.º 5
0
        //update password user
        public int UpdatePasswordUser(EC_tb_User ec_tb_use, bool data_type)
        {
            string sql = "";

            if (!data_type)
            {
                sql = "UPDATE [tb_User] SET [Password] = '" + ec_tb_use.Password + "' WHERE [ID] = " + ec_tb_use.ID;
            }
            else
            {
                sql = "UPDATE [tb_User] SET [Password] = N'" + ec_tb_use.Password + "' WHERE [ID] = " + ec_tb_use.ID;
            }

            return(ConnectionDB.ExecuteNonQuery(sql));
        }
Exemplo n.º 6
0
        //update User non password
        public int UpdateUserNonPassword(EC_tb_User ec_tb_use, bool data_type)
        {
            string sql = "";

            if (!data_type)
            {
                sql = "UPDATE [tb_User] SET [Name] ='" + ec_tb_use.Name + "', [Email] = '" + ec_tb_use.Email + "', [Address] = '" + ec_tb_use.Address + "', [Question] ='" + ec_tb_use.Question + "',[Answer] ='" + ec_tb_use.Answer + "' WHERE [ID]=" + ec_tb_use.ID;
            }
            else
            {
                sql = "UPDATE [tb_User] SET [Name] = N'" + ec_tb_use.Name + "', [Email] = N'" + ec_tb_use.Email + "', [Address] = N'" + ec_tb_use.Address + "', [Question] = N'" + ec_tb_use.Question + "', [Answer] = N'" + ec_tb_use.Answer + "' WHERE [ID] = " + ec_tb_use.ID;
            }

            return(ConnectionDB.ExecuteNonQuery(sql));
        }
Exemplo n.º 7
0
        //insert User
        public int InsertUser(EC_tb_User ec_tb_use, bool data_type)
        {
            string sql = "";

            if (!data_type)
            {
                sql = "INSERT INTO [tb_User] ([Name],[Email],[Address],[Password],[Question],[Answer]) VALUES('" + ec_tb_use.Name + "','" + ec_tb_use.Email + "','" + ec_tb_use.Address + "','" + ec_tb_use.Password + "','" + ec_tb_use.Question + "','" + ec_tb_use.Answer + "')";
            }
            else
            {
                sql = "INSERT INTO [tb_User] ([Name],[Email],[Address],[Password],[Question],[Answer]) VALUES(N'" + ec_tb_use.Name + "', N'" + ec_tb_use.Email + "', N'" + ec_tb_use.Address + "', N'" + ec_tb_use.Password + "', N'" + ec_tb_use.Question + "', N'" + ec_tb_use.Answer + "')";
            }

            return(ConnectionDB.ExecuteNonQuery(sql));
        }
Exemplo n.º 8
0
        //delete User
        public int DeleteUser(EC_tb_User ec_tb_use)
        {
            string sql = "DELETE FROM [tb_User] WHERE [ID]=" + ec_tb_use.ID;

            return(ConnectionDB.ExecuteNonQuery(sql));
        }
Exemplo n.º 9
0
        public bool Kiemtrauser(EC_tb_User user)
        {
            string sql = "select count(*) from tb_User where Username ='******' and Password = '******'";

            return(cn.KiemtraUsername(sql));
        }
Exemplo n.º 10
0
        //btnOK_Click
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                EC_tb_User ec_tb_user = new EC_tb_User();
                ec_tb_user.ID       = Convert.ToInt32(tblID.Text.Trim().ToString());
                ec_tb_user.Name     = StaticClass.GeneralClass.HandlingSpecialCharacter(tblName.Text.Trim().ToString());
                ec_tb_user.Email    = StaticClass.GeneralClass.HandlingSpecialCharacter(txbEmail.Text.Trim().ToString());
                ec_tb_user.Address  = StaticClass.GeneralClass.HandlingSpecialCharacter(txbAddress.Text.Trim().ToString());
                ec_tb_user.Question = StaticClass.GeneralClass.HandlingSpecialCharacter(txbQuestion.Text.Trim().ToString());
                ec_tb_user.Answer   = StaticClass.GeneralClass.HandlingSpecialCharacter(txbAnswer.Text.Trim().ToString());

                if (pwbPassword.Password.Trim() == "" && pwbConfirmPassword.Password.Trim() != "")
                {
                    tblNotification.Text = FindResource("password_null").ToString();
                    pwbConfirmPassword.Focus();
                    return;
                }

                if (pwbPassword.Password != "" && pwbConfirmPassword.Password == "")
                {
                    tblNotification.Text = FindResource("confirm_password_null").ToString();
                    pwbPassword.Focus();
                    return;
                }

                if (pwbPassword.Password.Trim() != "" && pwbConfirmPassword.Password.Trim() != "")
                {
                    if (pwbPassword.Password != pwbConfirmPassword.Password)
                    {
                        tblNotification.Text = FindResource("new_password_confirm_password_incorrect").ToString();
                        pwbConfirmPassword.Focus();
                        return;
                    }
                    else
                    {
                        ec_tb_user.Password = StaticClass.GeneralClass.MD5Hash(pwbPassword.Password.Trim().ToString());
                        if (bus_tb_user.UpdateUser(ec_tb_user, StaticClass.GeneralClass.flag_database_type_general) == 1)
                        {
                            if (btnedit_delegate != null)
                            {
                                btnedit_delegate();
                                this.Close();
                            }
                        }
                        else
                        {
                            ec_tb_user.Password = "";
                        }
                    }
                }
                else
                {
                    if (bus_tb_user.UpdateUserNonPassword(ec_tb_user, StaticClass.GeneralClass.flag_database_type_general) == 1)
                    {
                        if (btnedit_delegate != null)
                        {
                            btnedit_delegate();
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                tblNotification.Text = ex.Message;
            }
        }
Exemplo n.º 11
0
        //btnOK_Click
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (pwbCurrentPassword.Password.Trim() == "")
                {
                    tblNotification.Text = FindResource("current_password_null").ToString();
                    pwbCurrentPassword.Focus();
                    return;
                }

                if (pwbNewPassword.Password.Trim() == "")
                {
                    tblNotification.Text = FindResource("new_password_null").ToString();
                    pwbNewPassword.Focus();
                    return;
                }

                if (pwbNewPassword.Password.Trim().Length < 3)
                {
                    tblNotification.Text = FindResource("password_short").ToString();
                    pwbNewPassword.Focus();
                    return;
                }

                if (pwbConfirmPassword.Password.Trim() == "")
                {
                    tblNotification.Text = FindResource("confirm_password_null").ToString();
                    pwbConfirmPassword.Focus();
                    return;
                }

                else
                {
                    if (StaticClass.GeneralClass.MD5Hash(pwbCurrentPassword.Password.Trim().ToString()) != StaticClass.GeneralClass.password_user_general)
                    {
                        tblNotification.Text = FindResource("current_password_incorrect").ToString();
                        pwbCurrentPassword.Focus();
                        return;
                    }

                    if (StaticClass.GeneralClass.MD5Hash(pwbNewPassword.Password.Trim().ToString()) != StaticClass.GeneralClass.MD5Hash(pwbConfirmPassword.Password.Trim().ToString()))
                    {
                        tblNotification.Text = FindResource("new_password_confirm_password_incorrect").ToString();
                        pwbConfirmPassword.Focus();
                        return;
                    }

                    else
                    {
                        EC_tb_User ec_tb_user = new EC_tb_User();
                        ec_tb_user.ID       = StaticClass.GeneralClass.id_user_general;
                        ec_tb_user.Password = StaticClass.GeneralClass.MD5Hash(pwbNewPassword.Password.Trim().ToString());

                        if (bus_tb_user.UpdatePasswordUser(ec_tb_user, StaticClass.GeneralClass.flag_database_type_general) == 1)
                        {
                            StaticClass.GeneralClass.password_user_general = ec_tb_user.Password;

                            //return account page
                            BBCodeBlock bbcodeblock = new BBCodeBlock();
                            bbcodeblock.LinkNavigator.Navigate(new Uri("/Pages/Setting/Account.xaml", UriKind.Relative), this);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Pages.Notification page = new Pages.Notification();
                page.tblNotification.Text = ex.Message;
                page.ShowDialog();
            }
        }
Exemplo n.º 12
0
        private void GetUser()
        {
            if (thread_content != null && thread_content.ThreadState == ThreadState.Running)
            {
            }
            else
            {
                thread_content = new Thread(() =>
                {
                    try
                    {
                        this.grContent.Dispatcher.Invoke((Action)(() =>
                        {
                            dtgUser.ItemsSource = null;
                            this.dtgUser.Visibility = System.Windows.Visibility.Hidden;
                        }));

                        this.mpr.Dispatcher.Invoke((Action)(() =>
                        {
                            this.mpr.Visibility = System.Windows.Visibility.Visible;
                            this.mpr.IsActive = true;
                        }));

                        tb_user.Clear();
                        list_ec_tb_user.Clear();

                        tb_user = bus_tb_user.GetUser("");
                        foreach (DataRow datarow in tb_user.Rows)
                        {
                            EC_tb_User ec_tb_user = new EC_tb_User();
                            ec_tb_user.ID         = Convert.ToInt32(datarow["ID"].ToString());
                            ec_tb_user.Name       = datarow["Name"].ToString();
                            ec_tb_user.Email      = datarow["Email"].ToString();
                            ec_tb_user.Address    = datarow["Address"].ToString();
                            ec_tb_user.Password   = datarow["Password"].ToString();
                            ec_tb_user.Question   = datarow["Question"].ToString();
                            ec_tb_user.Answer     = datarow["Answer"].ToString();
                            ec_tb_user.EditImage  = @"pack://application:,,,/Resources/edit.png";

                            list_ec_tb_user.Add(ec_tb_user);
                        }

                        this.tblTotal.Dispatcher.Invoke((Action)(() => { tblTotal.Text = FindResource("total").ToString() + "(" + list_ec_tb_user.Count.ToString() + ")"; }));
                        this.dtgUser.Dispatcher.Invoke((Action)(() => { dtgUser.ItemsSource = list_ec_tb_user; }));

                        Thread.Sleep(500);
                        this.mpr.Dispatcher.Invoke((Action)(() =>
                        {
                            this.mpr.Visibility = System.Windows.Visibility.Hidden;
                            this.mpr.IsActive = false;
                        }));
                        this.grContent.Dispatcher.Invoke((Action)(() => { this.dtgUser.Visibility = System.Windows.Visibility.Visible; }));
                    }
                    catch (Exception ex)
                    {
                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            ModernDialog md = new ModernDialog();
                            md.CloseButton.Content = FindResource("close").ToString();
                            md.Title = FindResource("notification").ToString();
                            md.Content = ex.Message;
                            md.ShowDialog();
                        }));
                    }
                });
                thread_content.Start();
            }
        }
Exemplo n.º 13
0
 //delete User
 public int DeleteUser(EC_tb_User ec_tb_use)
 {
     return(sql_tb_use.DeleteUser(ec_tb_use));
 }
Exemplo n.º 14
0
 //update password user
 public int UpdatePasswordUser(EC_tb_User ec_tb_use, bool data_type)
 {
     return(sql_tb_use.UpdatePasswordUser(ec_tb_use, data_type));
 }
Exemplo n.º 15
0
 //inser User
 public int InsertUser(EC_tb_User ec_tb_use, bool data_type)
 {
     return(sql_tb_use.InsertUser(ec_tb_use, data_type));
 }