예제 #1
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();
        }
예제 #2
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();
        }
예제 #3
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();
        }