private void btnSaveAccount_Click(object sender, EventArgs e)
        {
            string UserName = txtUserName.Text;
            string Pass     = txtPass.Text;
            string Type     = cbLoaiTK.SelectedItem.ToString();

            try
            {
                int type = 1;
                if (Type.Equals("Employee"))
                {
                    type = 2;
                }
                string status = Account.InsertAccount(UserName, Pass, type);
                if (status != "Successful")
                {
                    throw new Exception(status);
                }
                MessageBox.Show("Thêm thành công", "STATUS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ResetGroupBoxAccount();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
 public void Execute()
 {
     var ds = accountBal.GetListAccount();
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         var salt = CreateSalt();
         var account = new Account()
         {
             ID = int.Parse(ds.Tables[0].Rows[i][0].ToString()),
             Username = ds.Tables[0].Rows[i][1].ToString(),
             Password = GenerateHash(ds.Tables[0].Rows[i][2].ToString(), salt),
             Salt = salt,
             Email = ds.Tables[0].Rows[i][3].ToString(),
             CrearedDateTime =
                 GenerateDateTime(Convert.ToDateTime(ds.Tables[0].Rows[i][4]).ToString("yyyy-MM-dd"),
                     ds.Tables[0].Rows[i][5].ToString()),
         };
         accountBal.InsertAccount(account);
         Console.WriteLine(account.ID);
     }
 }