public static void deleteUser(UserData u)
        {
            // CALL `p_delete_user`(@_user_id);
            try
            {
                using (MySqlConnection conn = new MySqlConnection(App.setting.connectString))
                {
                    conn.Open();
                    string query = "CALL `p_delete_user` (@_user_id);";

                    using (MySqlCommand cmd = new MySqlCommand(query, conn))
                    {
                        cmd.Parameters.AddWithValue("@_user_id", u.ID);
                        cmd.ExecuteNonQuery();
                    };
                    conn.Close();
                };
            }
            catch (MySqlException)
            {

            }
            catch (Exception)
            {

            }
        }
 void tmpItem_BrowserMediaEvent(object sender, UserData e)
 {
     GridMedia tmpMediaItem = new GridMedia();
     tmpMediaItem.BackEvent += tmpMediaItem_BackEvent;
     tmpMediaItem.Width = 1366;
     tmpMediaItem.Height = 668;
     double itemPostion = 0;
     if (UIContent.Children.Count > 0)
         itemPostion = UIContent.Children[UIContent.Children.Count - 1].getLeft();
     tmpMediaItem.setLeft(itemPostion - 1366);
     tmpMediaItem.setTop(0);
     tmpMediaItem.User = e;
     this.UIContent.Children.Add(tmpMediaItem);
     UIContent.Animation_Translate_Frame(double.NaN, double.NaN, -itemPostion + 1366, double.NaN, 500);
 }
 void item_BroswerMediaEvent(object sender, UserData e)
 {
     if (e != null && BrowserMediaEvent!=null)
     {
         BrowserMediaEvent(this, e);
     }
 }
 private void Item_CloseEvent(object sender, UserData e)
 {
     if (e != null)
     {
         bool isEditUser = false;
         foreach (UIUser item in this.list_Box_Item.Items)
         {
             if (item.User.ID == e.ID)
             {
                 item.User = e;
                 isEditUser = true;
                 break;
             }
         }
         if (!isEditUser)
         {
             this.Datas = App.curUser.getListUser(this.from, this.to, out this.totalUser);
             LoadGUI();
         }
     }
     this.UIRoot.Children.Remove(sender as UIUserEdit);
 }
        private void Item_DeleteUserEvent1(object sender, UserData e)
        {
            if (e != null)
            {
                UIUser uiU = this.list_Box_Item.SelectedItem as UIUser;
                this.list_Box_Item.SelectedIndex = -1;
                uiU.Animation_Opacity_View_Frame(false, () =>
                {
                    this.list_Box_Item.Items.Remove(uiU);
                    this.Datas.Remove(uiU.User);
                    if (this.to < this.totalUser)
                    {
                        this.Datas = App.curUser.getListUser(from, to, out totalUser);
                        LoadGUI();
                    }
                });

            }
            this.UIRoot.Children.Remove(sender as UIUserEdit);
        }
 private void Item_ViewInfouserEvent(object sender, UserData e)
 {
     if (e != null)
     {
         UIUserEdit item = new UIUserEdit();
         item.setLeft(0);
         item.setTop(90);
         item.Width = 1366;
         item.Height = 578;
         item.User = e;
         item.CloseEvent += Item_CloseEvent;
         item.DeleteUserEvent += Item_DeleteUserEvent1;
       
         this.UIRoot.Children.Add(item);
     }
 }
        public static List<UserData> toUsers(this MySqlDataReader reader)
        {
            if (reader.HasRows)
            {
                List<UserData> results = new List<UserData>();
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0))
                    {
                        UserData u = new UserData();
                        u.ID = reader.GetInt32(Define.user_id);
                        u.Full_Name = reader.GetString(Define.user_full_name);
                        u.Permision = Permision.Read(reader.GetString(Define.user_permision));
                        u.Status = reader.GetBoolean(Define.user_status);
                        u.Type = reader.GetInt32(Define.user_type);
                        u.Time = reader.GetDateTime(Define.user_time);
                        u.setDirectpass(reader.GetString(Define.user_pass));
                        try
                        {
                            u.Comment = reader.GetString(Define.user_content);
                        }
                        catch (Exception)
                        {
                        }
                        try
                        {
                            u.Phone = reader.GetString(Define.user_phone);
                        }
                        catch (Exception)
                        {
                        }
                        try
                        {
                            u.Email = reader.GetString(Define.user_email);
                        }
                        catch (Exception)
                        {
                        }
                        u.User_Name = reader.GetString(Define.user_name);
                        results.Add(u);
                    }

                }
                return results;
            }
            return null;
        }
        public static UserData toUser(this MySqlDataReader reader)
        {
            UserData u = null;
            while (reader.Read())
            {
                if (!reader.IsDBNull(0))
                {
                    u = new UserData();
                    u.ID = reader.GetInt32(Define.user_id);
                    u.Full_Name = reader.GetString(Define.user_full_name);
                    u.Permision = Permision.Read(reader.GetString(Define.user_permision));
                    u.Status = reader.GetBoolean(Define.user_status);
                    u.Type = reader.GetInt32(Define.user_type);
                    u.Time = reader.GetDateTime(Define.user_time);
                    u.User_Name = reader.GetString(Define.user_name);
                    u.setDirectpass(reader.GetString(Define.user_pass));
                    try
                    {
                        u.Comment = reader.GetString(Define.user_content);
                    }
                    catch (Exception)
                    {
                    }
                    try
                    {
                        u.Phone = reader.GetString(Define.user_phone);
                    }
                    catch (Exception)
                    {
                    }

                    try
                    {
                        u.Email = reader.GetString(Define.user_email);
                    }
                    catch (Exception)
                    {
                    }

                    try
                    {
                        u.Finger_Print = new byte[10*1024*1024];
                        long  bytesRead=reader.GetBytes(reader.GetOrdinal(Define.user_finger_print), 0, u.Finger_Print, 0, u.Finger_Print.Length);
                        Console.WriteLine(bytesRead + " bytes downloaded from table to file."); 
                    }
                    catch (Exception)
                    {

                    }
                }
            }
            return u;
        }
        public static int insertUser(UserData u)
        {
            int result = 0;
            try
            {

                using (MySqlConnection conn = new MySqlConnection(App.setting.connectString))
                {
                    conn.Open();
                    string query = "`p_insert_user`";
                    using (MySqlCommand cmd = new MySqlCommand(query, conn))
                    {
                        cmd.Parameters.Add(new MySqlParameter("@_fullname", MySqlDbType.Text) { Direction = System.Data.ParameterDirection.Input, Value = u.Full_Name });
                        cmd.Parameters.Add(new MySqlParameter("@_user_name", MySqlDbType.VarChar, 100) { Direction = System.Data.ParameterDirection.Input, Value = u.User_Name });
                        cmd.Parameters.Add(new MySqlParameter("@_user_pass", MySqlDbType.VarChar, 100) { Direction = System.Data.ParameterDirection.Input, Value = u.Pass });
                        cmd.Parameters.Add(new MySqlParameter("@_user_type", MySqlDbType.Int32) { Direction = System.Data.ParameterDirection.Input, Value = u.Type });
                        cmd.Parameters.Add(new MySqlParameter("@_user_phone", MySqlDbType.VarChar, 100) { Direction = System.Data.ParameterDirection.Input, Value = u.Phone });
                        cmd.Parameters.Add(new MySqlParameter("@_user_email", MySqlDbType.VarChar, 100) { Direction = System.Data.ParameterDirection.Input, Value = u.Email });
                        cmd.Parameters.Add(new MySqlParameter("@_user_finger_print", MySqlDbType.LongBlob) { Direction = System.Data.ParameterDirection.Input, Value = u.Finger_Print });
                        cmd.Parameters.Add(new MySqlParameter("@_result", MySqlDbType.Int32) { Direction = System.Data.ParameterDirection.Output, Value = 0 });
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        cmd.ExecuteScalar();
                        result = Convert.ToInt32(cmd.Parameters["@_result"].Value);

                    };
                    conn.Close();
                };
            }
            catch (Exception)
            {

            }
            return result;
        }