Exemplo n.º 1
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            while (true)
            {
                string id = textBoxID.Text.Trim();
                if (id.Length <= 0)
                {
                    MessageBox.Show("Chưa nhập ID", "Alert");
                    break;
                }
                string name = textBoxName.Text.Trim();
                if (name.Length <= 0)
                {
                    MessageBox.Show("Chưa nhập tên", "Alert");
                    break;
                }
                string phone = textBoxSDT.Text.Trim();
                if (phone.Length <= 0)
                {
                    MessageBox.Show("Chưa nhập số điện thoại", "Alert");
                    break;
                }
                if (Khach.CheckUserID(int.Parse(id)))
                {
                    MessageBox.Show("Id được chọn đã tồn tại", "Alert");
                    break;
                }

                string uname = textBoxuname.Text;
                if (uname.Length <= 0)
                {
                    MessageBox.Show("Chưa nhập tên tài khoản", "Alert");
                    break;
                }
                string pass = textBoxpass.Text;
                if (pass.Length <= 0)
                {
                    MessageBox.Show("Chưa nhập mật khẩu", "Alert");
                    break;
                }
                if (Khach.CheckUserName(uname))
                {
                    MessageBox.Show("Tên tài khoản đã có trong database", "Alert");
                    break;
                }
                string rank  = comboBoxRank.Text;
                int    point = (int)numericUpDownpoint.Value;
                string bdate = dateTimePickerdate.Value.ToString("yyyy-MM-dd");
                Random rnd   = new Random();
                int    i     = rnd.Next(100, 1000);

                //MessageBox.Show(id + " " + name + " " + type + " " + pro + " " + count + " " + cost + " " + date);
                string a = khach.AddKhach(id, name, rank, point, bdate, phone, i, uname, pass);
                MessageBox.Show(a);
                break;
            }
        }
Exemplo n.º 2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string user = txtUser.Text.ToString();
            string pass = txtPass.Text.ToString();

            if (Khach.CheckUserName(user))
            {
                MessageBox.Show("Tên tài khoản đã có trong database", "Alert");
            }
            else
            {
                string type = cbxType.GetItemText(cbxType.SelectedItem).ToString();
                try
                {
                    BLAccount.Instance.AddAcount(user, pass, type);
                    MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    MessageBox.Show("Lỗi truy cập Database", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }