Пример #1
0
        public void UpdateStatusBill(Bill_Show bill_)
        {
            var t = db.Output_Form.Find(bill_.ID_output);

            t.Status = "Complete";
            db.SaveChanges();
        }
Пример #2
0
        public ObservableCollection <Bill_Show> Load_ListBill()
        {
            ObservableCollection <Output_Form> out_form = new ObservableCollection <Output_Form>(db.Output_Form);
            ObservableCollection <Bill_Show>   a        = new ObservableCollection <Bill_Show>();

            for (int i = 0; i < out_form.Count; i++)
            {
                Bill_Show n = new Bill_Show();
                n.ID_output     = out_form[i].ID_Output;
                n.Namepro       = db.Detail_Product.Find(out_form[i].ID_Product).NameProduct;
                n.Initial_price = n.Sale_price = Int32.Parse(db.Detail_Product.Find(out_form[i].ID_Product).Original_Price.ToString());
                n.Name_Cus      = db.Customers.Find(out_form[i].ID_Customer).Name_Cus;
                n.status        = out_form[i].Status;
                n.ID_PRO        = out_form[i].ID_Product;
                n.Online        = out_form[i].BuyOnline;
                n.Amount        = (Int32)out_form[i].Amount;
                n.DateCreate    = (DateTime)out_form[i].Output_Date;
                n.Phone         = db.Customers.Find(out_form[i].ID_Customer).Phone;
                n.Ship          = (int)out_form[i].Ship;
                n.Address       = db.Customers.Find(out_form[i].ID_Customer).Address_Cus;
                n.Email         = db.Customers.Find(out_form[i].ID_Customer).Email == "" ? "" : db.Customers.Find(out_form[i].ID_Customer).Email;
                n.birthday      = (DateTime)db.Customers.Find(out_form[i].ID_Customer).Birthday;
                //lấy danh sách các Bill để show lên listbill
                a.Add(n);
            }

            return(a);
        }
Пример #3
0
        public void CancelBill(Bill_Show bill)
        {
            var curProduct = db.Detail_Product.Find(bill.ID_PRO);
            var curBill    = db.Output_Form.Find(bill.ID_output);

            // Đưa lại vào kho
            curProduct.Amount_Current += (bill.Amount);  // Tính cả phần tặng

            // Cập nhật trạng thái
            curBill.Status = "Canceled";

            db.SaveChanges();
        }
Пример #4
0
        public void AddnewOutput(Bill_Show bill_)
        {
            Output_Form a = new Output_Form();

            a.ID_Output   = bill_.ID_output;
            a.ID_Product  = bill_.ID_PRO;
            a.Note        = "";
            a.Output_Date = bill_.DateCreate;
            a.Price_Sale  = bill_.Sale_price;
            a.Ship        = bill_.Ship;
            a.Status      = bill_.status;
            a.Amount      = bill_.Amount;
            a.BuyOnline   = bill_.Online;
            //nếu khách hàng đã tồn tại thì ko cần thêm vào
            if (db.Customers.Find(bill_.Phone) == null) //chưa tồn tại
            {
                Customer b = new Customer()
                {
                    ID_Customer = Create_NewIdCustomer_Auto(),
                    Phone       = bill_.Phone,
                    Name_Cus    = bill_.Name_Cus,
                    Address_Cus = bill_.Address == null ? "" : bill_.Address,
                    Email       = bill_.Email,
                    Birthday    = (DateTime)bill_.birthday,
                };
                a.ID_Customer = b.ID_Customer;

                db.Customers.Add(b);
            }
            else
            {
                a.ID_Customer = db.Customers.Find(bill_.Phone).ID_Customer;
            }

            db.Output_Form.Add(a);
            db.SaveChanges();
        }