Esempio n. 1
0
 private void UserFullBinding_Loaded(object sender, RoutedEventArgs e)
 {
     if (txbTypeAcc.Text == "0")
     {
         txbTypeAcc.Text = "Quản lý";
     }
     else if (txbTypeAcc.Text == "1")
     {
         txbTypeAcc.Text = "Nhân viên";
     }
     else if (txbTypeAcc.Text == "2")
     {
         txbTypeAcc.Text = "Kế toán";
     }
     if (cbbGender.Text == "Nam")
     {
         cbbGender.SelectedIndex = 0;
     }
     else if (cbbGender.Text == "Nữ")
     {
         cbbGender.SelectedIndex = 1;
     }
     else if (cbbGender.Text == "Khác")
     {
         cbbGender.SelectedIndex = 2;
     }
     perinf = PersonInforBUS.GetById(txbCMND.Text);
 }
Esempio n. 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int id = 0, salar = 0;

            try
            {
                id = int.Parse("0" + txtMa.Text);
            } catch { MessageBox.Show("Mã quá dài");  return; }
            string name = " " + txbName.Text;
            string CMND = "0" + txbCMND.Text;

            try
            {
                salar = int.Parse("0" + txbSalary.Text);
                if (salar < 0)
                {
                    MessageBox.Show("Nhập lương sai!");
                    return;
                }
            }
            catch { MessageBox.Show("Lương quá lớn"); return; }
            string userName = txbUserName.Text;
            PERSON newPer   = new PERSON()
            {
                ID = id
            };

            try
            {
                PersonBUS.Insert(newPer);
            }
            catch { MessageBox.Show("Mã người dùng đã tồn tại !"); return; }

            PERSONINFOR newPerInf = new PERSONINFOR()
            {
                NAME = name, ID_TT = CMND, ID = id
            };

            try
            {
                PersonInforBUS.Insert(newPerInf);
            }
            catch { MessageBox.Show("CMND đã tồn tại !"); return; }

            string strType = ((ComboBoxItem)cbbTypeAcc.SelectedItem).Content.ToString();
            int    type    = -1;

            if (strType == "Quản lý")
            {
                type = 0;
            }
            else if (strType == "Nhân viên")
            {
                type = 1;
            }
            else if (strType == "Kế toán")
            {
                type = 2;
            }
            else
            {
                MessageBox.Show("Hãy chọn loại tài khoản !"); return;
            }
            USERAPP userApp = new USERAPP()
            {
                IDPERSON = id, SALARY = salar, DAYJOIN = DateTime.Now
            };

            UserBUS.Insert(userApp);

            ACCOUNT newAcc = new ACCOUNT()
            {
                ID_USER = UserBUS.GetIdByIDPerson(id), USERNAME = userName, TYPE = type
            };

            try
            {
                AccountBUS.Insert(newAcc);
            }
            catch { MessageBox.Show("Tài khoản đã tồn tại !"); return; }
            MessageBox.Show("Thêm thành công");

            isOKAddNew = true;
        }
Esempio n. 3
0
 public static void Update(PERSONINFOR obj)
 {
     reps.Update(obj);
 }
Esempio n. 4
0
 public static PERSONINFOR Insert(PERSONINFOR obj)
 {
     return(reps.Insert(obj));
 }
Esempio n. 5
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            object Sdog = dogBox.SelectedItem;

            if (Sdog == null)
            {
                MessageBox.Show("Hãy chọn chó !");
                return;
            }
            int id;

            try
            {
                if (txbBill_ID.Text == "")
                {
                    MessageBox.Show("Mã KH không được rỗng !");
                    return;
                }
                id = int.Parse(txbBill_ID.Text);
            }
            catch { MessageBox.Show("Mã KH quá lớn !"); return; }
            if (txbBill_CMND.Text.Length > 10 || txbBill_CMND.Text.Length < 9)
            {
                MessageBox.Show("Số CMND không chính xác !");
                return;
            }
            if (CustomerBUS.GetByID(txbBill_ID.Text) != null)
            {
                MessageBox.Show("Mã khách hàng đã tồn tại !");
                return;
            }
            if (PersonInforBUS.GetById(txbBill_CMND.Text) != null)
            {
                MessageBox.Show("Số CMND đã tồn tại !");
                return;
            }
            if (txbIDBill.Text.Length > 10 || txbIDBill.Text.Length < 1)
            {
                MessageBox.Show("Mã hóa đơn không chính xác !");
                return;
            }
            if (PersonBUS.GetById(id.ToString()) != null)
            {
                MessageBox.Show("Mã KH đã tồn tại !");
                return;
            }

            PERSON per = new PERSON()
            {
                ID = id, NOTE = "Khách hàng nhận chó!"
            };
            PERSONINFOR perinf = new PERSONINFOR()
            {
                ID_TT  = txbBill_CMND.Text,
                ID     = id,
                EMAIL  = txbBill_Mail.Text,
                PHONE  = txbBill_SĐT.Text,
                NAME   = txbBill_Name.Text,
                gender = ((ComboBoxItem)cbbBill_gender.SelectedItem).Content.ToString()
            };
            ADDRESS add = new ADDRESS()
            {
                IDPERSON = txbBill_CMND.Text,
                STREET   = txbBill_Streets.Text,
                WARD     = txbBill_Ward.Text,
                DISTRICT = txbBill_District.Text
            };

            CUSTOMER cus = new CUSTOMER()
            {
                IDPERSON = id
            };

            DOG dog = DogBUS.GetById(txbIDDog.Text);

            dog.STATUS = 1;
            BILL_OUT bill_Out = new BILL_OUT()
            {
                ID_USER    = _acc.ID_USER,
                ID_BILL    = txbIDBill.Text,
                IDDOG      = int.Parse(txbIDDog.Text),
                DAY_BILL   = DateTime.Now,
                FINE       = long.Parse(txbFoodPrice.Text),
                TOTALPRICE = long.Parse(txbTotalPrice.Text)
            };

            PAYMENT_RECEIPT_VOUCHER pay = new PAYMENT_RECEIPT_VOUCHER()
            {
                DATETIME    = DateTime.Now,
                TYPE        = true,
                VALUE       = long.Parse(txbTotalPrice.Text),
                DESTRIPTION = "Nhận tiền trả chó !",
                ID_USER     = _acc.ID_USER,
            };

            if (MessageBox.Show("Xác nhận trả chó !", "", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
            {
                return;
            }

            try
            {
                PersonBUS.Insert(per);
            }
            catch { MessageBox.Show("Trả thất bại (per) !"); return; }
            try
            {
                PersonInforBUS.Insert(perinf);
            }
            catch
            {
                MessageBox.Show("Trả thất bại (perinf) !");
                PersonBUS.Delete(per);
                return;
            }
            try
            {
                AddressBUS.Insert(add);
            }
            catch
            {
                MessageBox.Show("Trả thất bại  (addr)!");
                PersonInforBUS.Delete(perinf);
                PersonBUS.Delete(per);
                return;
            }
            try
            {
                CustomerBUS.Insert(cus);
            }
            catch
            {
                MessageBox.Show("Trả thất bại (cus) !");
                AddressBUS.Delete(add);
                PersonInforBUS.Delete(perinf);
                PersonBUS.Delete(per);
                return;
            }
            try
            {
                bill_Out.ID_CUSTOMER = CustomerBUS.GetIdByIDPerson(id);
                BillOutBUS.Insert(bill_Out);
            }
            catch
            {
                MessageBox.Show("Trả thất bại  (billout)!");
                CustomerBUS.Delete(cus);
                AddressBUS.Delete(add);
                PersonInforBUS.Delete(perinf);
                PersonBUS.Delete(per);
                return;
            }
            try
            {
                Pay_ReceiptBUS.Insert(pay);
            }
            catch
            {
                MessageBox.Show("Trả thất bại (pay_receipt) !");
                BillOutBUS.Delete(bill_Out);
                CustomerBUS.Delete(cus);
                AddressBUS.Delete(add);
                PersonInforBUS.Delete(perinf);
                PersonBUS.Delete(per);
                return;
            }
            try
            {
                DogBUS.Update(dog);
            }
            catch
            {
                MessageBox.Show("Trả thất bại (dogupdate) !");
                Pay_ReceiptBUS.Delete(pay);
                BillOutBUS.Delete(bill_Out);
                CustomerBUS.Delete(cus);
                AddressBUS.Delete(add);
                PersonInforBUS.Delete(perinf);
                PersonBUS.Delete(per);
                return;
            }
            MessageBox.Show("Trả chó thành công !");
            LoadListDogs();
            RefreshBill();
        }
 public static void Delete(PERSONINFOR obj)
 {
     reps.Delete(obj);
 }