예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog op = new OpenFileDialog();

            op.ShowDialog();
            string fileName = op.FileName;

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }
            ImageDog = new BitmapImage(new Uri(fileName));
            if (MessageBox.Show("Cập hình hình ảnh cho chó ?", "", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                var t = dogBox.SelectedItem;
                if (t == null)
                {
                    MessageBox.Show("Chọn chó để cập nhật hình ảnh !");
                    return;
                }
                string idDog       = t.GetType().GetProperty("ID_DOG").GetValue(t, null).ToString();
                DOG    selectedDog = DogBUS.GetById(idDog);
                selectedDog.IMAGES = UIProcess.Inst.ImageToByteArray(ImageDog);
                DogBUS.Update(selectedDog);
                LoadListDogs();
            }
        }
예제 #2
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)//Cập nhật thông tin
        {
            int    macho = int.Parse(this.txbIDDog.Text);
            string loai  = this.txbIDTypeDog.Text.ToString();
            //bool thieuhuy = false;

            float cannang = float.Parse(this.txbWeight.Text);

            if (cannang <= 0 && cannang >= 30)
            {
                MessageBox.Show("Cân nặng không chính xác");
                this.txbWeight.Focus();
            }
            cannang = float.Parse(this.txbWeight.Text);
            DateTime ngay = DateTime.Parse(this.txtday.Text);



            string chuog = this.txbIDHouseDog.Text.ToString();

            int tienthucan = int.Parse(this.txbFoodPrice.Text);

            if (tienthucan < 1 && tienthucan > 200000)
            {
                MessageBox.Show("Tiền thức ăn phải hợp lệ");
                this.txbFoodPrice.Focus();
            }
            tienthucan = int.Parse(this.txbFoodPrice.Text);
            string tg = this.txttime.Text.ToString();
            //string[] a = tg.Split(' ');
            //TimeSpan time = TimeSpan.Parse(a[0]);
            //if (ngay == null)
            //{
            //    MessageBox.Show("Nhập giờ!");
            //    this.tgian.Focus();
            //}

            //tg = this.tgian.Text.ToString();
            //a = tg.Split(' ');
            //time = TimeSpan.Parse(a[0]);


            string idms = this.txbIDDog.Text.ToString();
            DOG    dog  = DogBUS.getByID(idms);

            dog.WEIGHT     = cannang;
            dog.TYPE       = loai;
            dog.DAYIN      = ngay;
            dog.FOODPRICE  = tienthucan;
            dog.IDDOGHOUSE = chuog;
            try
            {
                DogBUS.Update(dog);
            }
            catch { MessageBox.Show("Cập nhật bảng chó không thành công!"); return; }

            loadFromData();
        }
예제 #3
0
 void loadFromData()
 {
     _ListDogs = DogBUS.GetAll();
     try
     {
         foreach (var dog in _ListDogs)
         {
             var getProp  = dog.GetType().GetProperty("IMAGES");
             var newValue = Convert.ChangeType(UIProcess.Inst.LoadImage((byte[])getProp.GetValue(dog, null)), getProp.PropertyType);
             getProp.SetValue(dog, newValue, null);
         }
     }
     catch { }
     SetDataSource(_ListDogs);
 }
예제 #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Hủy tất cả chó trong danh sách này ?", "", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
            {
                return;
            }
            if (isXuat)
            {
                if (MessageBox.Show("Xuất file trước khi hủy?", "", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
                {
                    return;
                }
            }

            foreach (var item in lsDoyDetroy)
            {
                string id  = item.GetType().GetProperty("ID_DOG").GetValue(item, null).ToString();
                DOG    dog = DogBUS.getByID(id);
                dog.STATUS = 2;
                DogBUS.Update(dog);
            }
            listDogDetroy.ItemsSource = DogBUS.getAllDogDetroy();
        }
예제 #5
0
 void Search(string key)
 {
     _ListDogs          = DogBUS.search(key);
     dogBox.ItemsSource = _ListDogs;
 }
예제 #6
0
 void loadFromData()
 {
     _ListDogs = DogBUS.GetAll();
     SetDataSource(_ListDogs);
 }
예제 #7
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            float wei;
            long  fd;

            try
            {
                wei = float.Parse(txbnewWeight.Text);
                fd  = long.Parse(txbnewPricefood.Text);
            }
            catch { MessageBox.Show("Cân nặng hoặc tiền thức ăn không đúng !"); return; }
            string type = ((ComboBoxItem)(cbbnewtype.SelectedItem)).Content.ToString();

            if (txbIDBill.Text.Length <= 0 || txbIDBill.Text.Length > 10)
            {
                MessageBox.Show("Mã hóa đơn không đúng !");
                return;
            }
            if (txbIDBill.Text == "" || txbIDBill.Text == " ")
            {
                MessageBox.Show("Mã hóa đơn không được rỗng !");
                return;
            }
            BILL_IN bill = BillinBUS.GetById(txbIDBill.Text);

            if (bill != null)
            {
                MessageBox.Show("Mã hóa đơn đã tồn tại !");
                return;
            }
            if (type == "Loại 1")
            {
                type = "DTYPE_1";
            }
            else if (type == "Loại 2")
            {
                type = "DTYPE_2";
            }
            else if (type == "Loại 3")
            {
                type = "DTYPE_3";
            }

            string doghouse = ((ComboBoxItem)(cbbnewMaChuong.SelectedItem)).Content.ToString();

            if (doghouse == "Chuồng 1")
            {
                doghouse = "DH01";
            }
            else if (doghouse == "Chuồng 2")
            {
                doghouse = "DH02";
            }
            else if (doghouse == "Chuồng 3")
            {
                doghouse = "DH03";
            }

            byte[] dogimage = UIProcess.Inst.ImageToByteArray(ImageDog);
            DOG    newDog   = new DOG()
            {
                TYPE = type, WEIGHT = wei, FOODPRICE = fd, DAYIN = DateTime.Now, STATUS = 0, IDDOGHOUSE = doghouse, IMAGES = dogimage
            };
            DOG DogAferInset;

            try
            {
                DogAferInset = DogBUS.Insert(newDog);
            }
            catch { MessageBox.Show("Thất bại, kiểm tra kết nối !"); return; };
            DOG_INFOR doginfo = new DOG_INFOR()
            {
                STREET   = txbBill_Streets.Text,
                WARD     = txbBill_Ward.Text,
                DISTRICT = txbBill_District.Text,
                TIME     = TimeSpan.Parse(DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss")),
                IDDOG    = DogAferInset.ID
            };

            try
            {
                DogInforBUS.Insert(doginfo);
            }
            catch
            {
                DOG dogdelete = DogBUS.getByID(DogAferInset.ID.ToString());
                DogBUS.Delete(dogdelete);
                MessageBox.Show("Thêm thất bại, kiểm tra kết nối !");
                return;
            }

            BILL_IN billin = new BILL_IN()
            {
                IDDOG    = DogAferInset.ID,
                DAY_BILL = DateTime.Now,
                FINE     = long.Parse(txbnewPricefood.Text),
                ID_BILL  = txbIDBill.Text,
                ID_USER  = _acc.ID_USER,
            };

            BillinBUS.Insert(billin);
            LoadListDogs();

            MessageBox.Show("Thêm chó thành công !");
            ResetBillIn();
        }
예제 #8
0
        private void btnXuat_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Office.Interop.Excel._Application excel     = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel._Workbook    workbook  = excel.Workbooks.Add(Type.Missing);
            Microsoft.Office.Interop.Excel._Worksheet   worksheet = excel.ActiveSheet;
            excel.Visible = true;
            try
            {
                lsDoyDetroy = DogBUS.getAllDogDetroy();

                var row = 1;
                worksheet.Cells[1, "A"] = "Mã chó";
                worksheet.Cells[1, "B"] = "Ngày";
                worksheet.Cells[1, "C"] = "Loại";
                worksheet.Cells[1, "D"] = "Giá thức ăn";
                worksheet.Cells[1, "E"] = "Chuồng";
                worksheet.Cells[1, "F"] = "Đường";
                worksheet.Cells[1, "G"] = "Phường";
                worksheet.Cells[1, "H"] = "Quận";
                worksheet.Cells[1, "I"] = "Thời gian";
                worksheet.Cells[1, "J"] = "Số ngày";

                foreach (var st in lsDoyDetroy)
                {
                    row++;
                    worksheet.Cells[row, "A"] = st.GetType().GetProperty("ID_DOG").GetValue(st, null).ToString();
                    worksheet.Cells[row, "B"] = String.Format("{0:dd/MM/yyyy}", (st.GetType().GetProperty("DAYIN").GetValue(st, null).ToString()));
                    worksheet.Cells[row, "C"] = st.GetType().GetProperty("TYPE").GetValue(st, null).ToString();
                    worksheet.Cells[row, "D"] = st.GetType().GetProperty("FOODPRICE").GetValue(st, null).ToString();
                    worksheet.Cells[row, "E"] = st.GetType().GetProperty("IDDOGHOUSE").GetValue(st, null).ToString();
                    worksheet.Cells[row, "F"] = st.GetType().GetProperty("STREET").GetValue(st, null).ToString();
                    worksheet.Cells[row, "G"] = st.GetType().GetProperty("WARD").GetValue(st, null).ToString();
                    worksheet.Cells[row, "H"] = st.GetType().GetProperty("DISTRICT").GetValue(st, null).ToString();
                    worksheet.Cells[row, "I"] = String.Format("{0:hh/:mm}", st.GetType().GetProperty("TIME").GetValue(st, null).ToString());
                    worksheet.Cells[row, "J"] = st.GetType().GetProperty("NUMOFDAY").GetValue(st, null).ToString();
                }
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[1]).AutoFit();
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[2]).AutoFit();
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[3]).AutoFit();
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[4]).AutoFit();
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[5]).AutoFit();
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[6]).AutoFit();
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[7]).AutoFit();
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[8]).AutoFit();
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[9]).AutoFit();
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[10]).AutoFit();
                SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.Filter      = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
                saveDialog.FilterIndex = 2;
                Nullable <bool> result = saveDialog.ShowDialog();
                if (result == true)
                {
                    workbook.SaveAs(saveDialog.FileName);
                    MessageBox.Show("Xuất thành công!");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                excel.Quit();
                workbook = null;
                excel    = null;
            }
        }
예제 #9
0
 public Dog_Destroyed()
 {
     InitializeComponent();
     lsDoyDetroy = DogBUS.getAllDogDetroy();
 }
예제 #10
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();
        }