Beispiel #1
0
        public void TestCreateNewBill()
        {
            foreach (bool paid in new List <bool> {
                true, false
            })
            {
                MockBillReaderWriter billWriter = new MockBillReaderWriter();
                BillDetailViewModel  billDetail = new BillDetailViewModel(billWriter, null, new NavigatorViewModel());
                billDetail.Amount        = 1;
                billDetail.BillName      = "Test name";
                billDetail.BillType      = BillType.Food;
                billDetail.Description   = "Test description";
                billDetail.DueDate       = new DateTime(1990, 1, 1);
                billDetail.IsAlreadyPaid = paid;

                Assert.IsTrue(billDetail.OnRecordButtonClick.CanExecute(null));
                billDetail.OnRecordButtonClick.Execute(null);
                BillInfo actualBilLSaved = billWriter.BillSaved;

                Assert.AreEqual(actualBilLSaved.Amount, 1);
                Assert.AreEqual(actualBilLSaved.BillName, "Test name");
                Assert.AreEqual(actualBilLSaved.Type, BillType.Food);
                Assert.AreEqual(actualBilLSaved.Description, "Test description");
                Assert.AreEqual(actualBilLSaved.DueDate, new DateTime(1990, 1, 1));
                Assert.AreEqual(actualBilLSaved.IsAlreadyPaid, paid);
            }
        }
Beispiel #2
0
        // thanh toán tạo bill
        private void btnthanhtoan_Click(object sender, EventArgs e)
        {
            if (dgvbill.Rows.Count > 1)
            {
                string       userName  = Form1.getUserName;
                List <Staff> listStaff = StaffDAO.Instance.getStaffByUserName(userName);
                // lấy ra id nhân viên nhập đơn
                int idStaff = listStaff[0].Id;
                // lấy ra giảm giá
                string getDiscount = tbgiamgia.Text;
                long   discount    = 0;
                if (!getDiscount.Equals(""))
                {
                    discount = long.Parse(getDiscount);
                }
                // lấy ra ngày hiện tại

                var currentTime      = DateTime.Today.ToString("yyyy-MM-dd HH:mm:ss:fff");
                var parseCurrentTime = DateTime.ParseExact(currentTime, "yyyy-MM-dd HH:mm:ss:fff", CultureInfo.InvariantCulture);
                // lấy ra tổng tiền
                long total = long.Parse(tbtong.Text);

                Bill bill = new Bill
                {
                    idbill    = 1,
                    idAccount = idStaff,
                    total     = total,
                    founding  = parseCurrentTime,
                    discount  = discount,
                };
                bool checkAddBill = BillDAO.Instance.insertBill(bill);
                if (checkAddBill)
                {
                    for (int i = 0; i < dgvbill.Rows.Count - 1; i++)
                    {
                        BillInfo infor = new BillInfo
                        {
                            idbillInfor = 1,
                            idbill      = bill.idbill,
                            iddetail    = Int16.Parse(dgvbill.Rows[i].Cells[5].FormattedValue.ToString()),
                            amount      = Int16.Parse(dgvbill.Rows[i].Cells[3].FormattedValue.ToString()),
                            price       = long.Parse(dgvbill.Rows[i].Cells[4].FormattedValue.ToString()),
                        };
                        BillInforDAO.Instance.insert(infor);
                    }


                    dgvbill.Rows.Clear();
                    MessageBox.Show("Thêm Đơn Hàng Thành Công!");
                }
                else
                {
                    MessageBox.Show("Thêm Đơn Hàng Thất Bại!");
                }
            }
            else
            {
                MessageBox.Show("Chưa có sản phẩm để tạo đơn hàng!");
            }
        }
Beispiel #3
0
        public void SellerEntry(string billNo, decimal sumTotal, CustomerInfoDetails custInfo)
        {
            var database       = new InventoryEntities();
            var billTypeIDList = (from c in database.BillTypes
                                  where c.BillTypeName == "Cash"
                                  select new
            {
                c.BillTypeID
            }).FirstOrDefault();

            var custInfoTable = new CustomerInfo();
            var billInfoTable = new BillInfo();

            custInfoTable.CustomerName    = custInfo.custName;
            custInfoTable.CustomerAddress = custInfo.custAddress;
            custInfoTable.Mobile          = custInfo.custMobile;
            custInfoTable.Email           = custInfo.custEmail;
            database.CustomerInfoes.Add(custInfoTable);


            billInfoTable.BillNumber   = billNo;
            billInfoTable.BillTypeID   = billTypeIDList.BillTypeID;//Cash or Credit Bill
            billInfoTable.TotalAmount  = sumTotal;
            billInfoTable.Discount     = custInfo.custDiscount;
            billInfoTable.BillDate     = custInfo.billDate;
            billInfoTable.UpdatedOn    = DateTime.Now;
            billInfoTable.CustomerInfo = custInfoTable;
            //database.CustomerInfoes.Add(custInfoTable);
            database.BillInfoes.Add(billInfoTable);
            database.SaveChanges();
        }
 private void AddToDb(BillInfo bill)
 {
     using (DataAccessLayer dbAccess = new DataAccessLayer(_connString))
     {
         dbAccess.AddAndSave(bill);
     }
 }
Beispiel #5
0
        public async Task CreateUpdate(BillInfoInput input)
        {
            BillInfo result = _mapper.Map <BillInfo>(input);


            if (input.Id == null || input.Id.Equals(0))
            {
                //result.Bowser= _bowsersRepository.GetAll().Where(b => b.Id == input.BowserId).FirstOrDefault();
                //result.Company = _companyRepository.GetAll().Where(c=> c.Id == input.CompanyId).FirstOrDefault();
                //result.Employee=_employeeRepository.GetAll().Where(d => d.Id == input.EmployeeId).FirstOrDefault();
                var billInfo = _billInfoRepository.GetAll()
                               .OrderByDescending(x => x.Id)
                               .FirstOrDefault();

                result.BillNo = billInfo.BillNo + 1;

                await _billInfoRepository.Create(result);
            }

            else

            {
                result.Bowser = _bowsersRepository.GetAll().Where(b => b.Id == input.Id).FirstOrDefault();

                await _billInfoRepository.Update(input.Id, result);


                //result.Bowser = _bowsersRepository.GetAll().Where(b => b.BowserNoPlate == input.).FirstOrDefault();
                //await _billInfoRepository.Create(result);
            }
        }
Beispiel #6
0
        public ImageSaldoPage(BillInfo bill)
        {
            Period    = bill.Period;
            _billInfo = bill;
            _filename = _billInfo.Period + "_" + _billInfo.Ident.Replace("/", "")
                        .Replace("\\", "") + ".pdf";
            InitializeComponent();

            if (Device.RuntimePlatform == Device.iOS)
            {
                int statusBarHeight = DependencyService.Get <IStatusBar>().GetHeight();
                Pancake2.HeightRequest = statusBarHeight; // new Thickness(0, statusBarHeight, 0, 0);
            }

            // var pinchGesture = new PinchGestureRecognizer();
            // pinchGesture.PinchUpdated += OnPinchUpdated;
            //Image.GestureRecognizers.Add(pinchGesture);

            var backClick = new TapGestureRecognizer();

            backClick.Tapped += async(s, e) => { _ = await Navigation.PopAsync(); };
            BackStackLayout.GestureRecognizers.Add(backClick);
            LoadPdf();
            NavigationPage.SetHasNavigationBar(this, false);
            BindingContext = this;
        }
Beispiel #7
0
        public int insertBillInfo(BillInfo billInfo, ref string error)
        {
            string query = string.Format("INSERT INTO NGOCHOANG2.CHITIETHOADON (IDHOADON,IDORDER,SOLUONG) VALUES ({0},{1},{2})",
                                         billInfo.IdBill, billInfo.IdOrder, billInfo.Count);

            return(DataProvider.Instance.ExecuteNonQuery(query, ref error));
        }
Beispiel #8
0
        private void DoRequestBills()
        {
            BillList.Clear();
            SelectedBill = new BillInfo();
            Predicate <BillInfo> filterByPaidStatus = GetFilterByPaidStatus();
            Predicate <BillInfo> filterByDateTime   = GetFilterByDateTime();
            IList <BillInfo>     bills = new List <BillInfo>();

            try
            {
                bills = _billReaderWriter.GetBillByFilter(bill => filterByPaidStatus(bill) && filterByDateTime(bill));
            }
            catch (Exception e)
            {
                if (PopUpWinService == null)
                {
                    return;
                }

                PopUpWinService.Input = e.Message;
                PopUpWinService.DoModal();
            }

            foreach (BillInfo bill in bills)
            {
                BillList.Add(bill);
            }
        }
Beispiel #9
0
 public bool DeleteFromDB(BillInfo billInfo)
 {
     try
     {
         OpenConnection();
         string     queryString = "delete from BillInfo where idBill=" + billInfo.IdBill.ToString() + " and idGoods=" + billInfo.IdGoods.ToString();
         SqlCommand command     = new SqlCommand(queryString, conn);
         if (command.ExecuteNonQuery() < 1)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch
     {
         return(false);
     }
     finally
     {
         CloseConnection();
     }
 }
Beispiel #10
0
 public bool AddIntoDB(BillInfo billInfo)
 {
     try
     {
         OpenConnection();
         string     queryString = "insert into BillInfo(idBill, idGoods, quantity) values(@idBill, @idGoods, @quantity)";
         SqlCommand command     = new SqlCommand(queryString, conn);
         command.Parameters.AddWithValue("@idBill", billInfo.IdBill);
         command.Parameters.AddWithValue("@idGoods", billInfo.IdGoods);
         command.Parameters.AddWithValue("@quantity", billInfo.Quantity);
         int rs = command.ExecuteNonQuery();
         if (rs == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         CustomMessageBox.Show("Đã tồn tại mặt hàng", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
         return(false);
     }
     finally
     {
         CloseConnection();
     }
 }
Beispiel #11
0
        public bool UpdateOnDB(BillInfo billInfo)
        {
            try
            {
                OpenConnection();
                string     queryString = "update BillInfo set quantity=@quantity where idGoods=@idGoods and idBill=@idBill";
                SqlCommand command     = new SqlCommand(queryString, conn);
                command.Parameters.AddWithValue("@idGoods", billInfo.IdGoods.ToString());
                command.Parameters.AddWithValue("@idBill", billInfo.IdBill.ToString());
                command.Parameters.AddWithValue("@quantity", billInfo.Quantity.ToString());
                int rs = command.ExecuteNonQuery();
                if (rs != 1)
                {
                    return(false);

                    throw new Exception();
                }
                else
                {
                    return(true);
                }
            }
            catch
            {
                CustomMessageBox.Show("Thực hiện thất bại", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            finally
            {
                CloseConnection();
            }
        }
Beispiel #12
0
        public List <BillInfo> ConvertDBToList()
        {
            try
            {
                OpenConnection();
                string queryString = "select * from BillInfo";

                SqlCommand     command = new SqlCommand(queryString, conn);
                SqlDataAdapter adapter = new SqlDataAdapter(command);

                DataTable dataTable = new DataTable();
                adapter.Fill(dataTable);
                List <BillInfo> billInfos = new List <BillInfo>();

                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    BillInfo billInfo = new BillInfo(int.Parse(dataTable.Rows[i].ItemArray[0].ToString()), int.Parse(dataTable.Rows[i].ItemArray[1].ToString()),
                                                     int.Parse(dataTable.Rows[i].ItemArray[2].ToString()));
                    billInfos.Add(billInfo);
                }
                return(billInfos);
            }
            catch
            {
                return(new List <BillInfo>());
            }
            finally
            {
                CloseConnection();
            }
        }
Beispiel #13
0
        public int insert(int idBill, int idFood, int count, int idTable)
        {
            int idBill1 = 0;

            if (idBill == -1)
            {
                idBill1 = BillDAO.Instance.insert(DateTime.Now, DateTime.Now, idTable, 1);
            }
            else
            {
                idBill1 = idBill;
            }
            // Trộn billInfo
            if (BillInfoDao.Instance.getBillInfo(idBill1, idFood).Rows.Count > 0)
            {
                DataTable dt  = BillInfoDao.Instance.getBillInfo(idBill1, idFood);
                BillInfo  bIf = new BillInfo();
                bIf.ID      = (int)dt.Rows[0]["id"];
                bIf.IdBill  = (int)dt.Rows[0]["idBill"];
                bIf.IdFood  = (int)dt.Rows[0]["idFood"];
                bIf.Count1  = (int)dt.Rows[0]["count1"];
                bIf.Count1 += count;
                BillInfoDao.Instance.updateBill(bIf);
            }
            else
            {
                BillInfoDao.Instance.insert(idBill1, idFood, count);
            }

            return(idBill1);
        }
Beispiel #14
0
        public async Task <BillInfo> UpdateBillAsync(BillInfo bill)
        {
            _context.BillInfos.Update(bill);
            await _context.SaveChangesAsync();

            return(bill);
        }
Beispiel #15
0
        public async Task <BillInfo> DeleteBillAsync(BillInfo bill)
        {
            _context.BillInfos.Remove(bill);
            await _context.SaveChangesAsync();

            return(bill);
        }
Beispiel #16
0
        public IActionResult AddBill(Bill bill)
        {
            _context.Bill.Add(bill);
            _context.SaveChangesAsync();

            string json     = HttpContext.Session.GetString("Cart");
            var    itemList = JsonConvert.DeserializeObject <List <Item> >(json);

            foreach (Item item in itemList)
            {
                BillInfo billInfo = new BillInfo()
                {
                    billId     = bill.id,
                    computerId = item.computer.id,
                    price      = item.computer.price,
                    quanLiTy   = item.quanLiTy
                };

                _context.BillInfo.Add(billInfo);
                _context.SaveChangesAsync();
                HttpContext.Session.Clear();
            }

            return(NoContent());
        }
Beispiel #17
0
        public bool Record(BillInfo bill, out string errorString)
        {
            if (bill == null)
            {
                errorString = "Cannot save null bills";
                return(false);
            }

            if (bill.Id == 0)
            {
                using (DataAccessLayer dbAccess = new DataAccessLayer(_connString))
                {
                    errorString = "";
                    return(dbAccess.AddAndSave(bill));
                }
            }
            else
            {
                using (DataAccessLayer dbAccess = new DataAccessLayer(_connString))
                {
                    errorString = "";
                    return(dbAccess.ModifyAndSave(bill));
                }
            }
        }
Beispiel #18
0
        public List <BillInfo> GetBillInfo(BAN table)
        {
            var list = from hanghoa in db.HANGHOAs
                       from hoadon in db.HOA_DON
                       from hoadonChitiet in db.CHI_TIET_HOA_DON
                       where hanghoa.ID_HH == hoadonChitiet.ID_HH
                       where hoadon.ID_HD == hoadonChitiet.ID_HD
                       where hoadon.ID_BAN == table.ID_BAN
                       where hoadon.Gio_di == null
                       let tongTien = hoadonChitiet.soluong * (double)hanghoa.Gia
                                      select new { hanghoa.Ten_HH, hoadonChitiet.soluong, hanghoa.Gia, tongTien };

            List <BillInfo> listBillIn = new List <BillInfo>();

            foreach (var item in list)
            {
                BillInfo temp = new BillInfo
                {
                    MatHang  = item.Ten_HH,
                    SoLuong  = (int)item.soluong,
                    DonGia   = (double)item.Gia,
                    TongTien = (double)item.tongTien
                };
                listBillIn.Add(temp);
            }

            return(listBillIn);
        }
        public void TestSqlListBillReaderWithFilterByPaidStatus()
        {
            List <BillInfo> bills  = new List <BillInfo>();
            List <int>      newIds = new List <int> {
                _currId + 1, _currId + 2, _currId + 3, _currId + 4
            };
            IDictionary <int, bool> paidstatus = new Dictionary <int, bool>
            {
                { newIds[0], true },
                { newIds[1], false },
                { newIds[2], true },
                { newIds[3], true }
            };

            foreach (int expectedId in newIds)
            {
                BillInfo bill = GenerateRandomBillInfo(expectedId);
                bill.IsAlreadyPaid = paidstatus[expectedId];
                AddToDb(bill);
                bills.Add(bill);
            }

            SqliteDbBillReaderWriter sqliteReader = new SqliteDbBillReaderWriter(_connString);
            IList <BillInfo>         paidBills    = sqliteReader.GetBillByFilter(bill => bill.IsAlreadyPaid);

            Assert.AreEqual(paidBills.Count, 3);
            Assert.AreEqual(paidBills[0].Id, newIds[0]);
            Assert.AreEqual(paidBills[1].Id, newIds[2]);
            Assert.AreEqual(paidBills[2].Id, newIds[3]);

            IList <BillInfo> unpaidBills = sqliteReader.GetBillByFilter(bill => !bill.IsAlreadyPaid);

            Assert.AreEqual(unpaidBills.Count, 1);
            Assert.AreEqual(unpaidBills[0].Id, newIds[1]);
        }
        public void SetUp()
        {
            _mutex.WaitOne();
            System.Diagnostics.Debug.WriteLine("Begin test " + TestContext.TestName);
            using (DataAccessLayer dbAccess = new DataAccessLayer(_connString))
            {
                BillInfo dummy = new BillInfo {
                    Type = BillType.Unknown, BillName = "", Amount = 0.0, DueDate = new DateTime(1990, 1, 1)
                };
                dbAccess.AddAndSave(dummy);
                _currId = dummy.Id;
            }

            try
            {
                CleanDatabase();
            }
            catch (Exception e)
            {
                ConsoleColor original = Console.BackgroundColor;
                Console.BackgroundColor = ConsoleColor.DarkRed;
                Console.WriteLine(e.Message);
                Console.BackgroundColor = original;
            }
        }
 private void ModifyAndSave(BillInfo bill)
 {
     using (DataAccessLayer dbAccess = new DataAccessLayer(_connString))
     {
         dbAccess.ModifyAndSave(bill);
     }
 }
        public void TestSqlListBillReaderWithFilterByDateTime()
        {
            IList <BillInfo> bills  = new List <BillInfo>();
            List <int>       newIds = new List <int> {
                _currId + 1, _currId + 2, _currId + 3, _currId + 4
            };
            IDictionary <int, DateTime> duedates = new Dictionary <int, DateTime>
            {
                { newIds[0], new DateTime(1990, 10, 1) },
                { newIds[1], new DateTime(1990, 10, 2) },
                { newIds[2], new DateTime(1990, 10, 3) },
                { newIds[3], new DateTime(1990, 10, 4) }
            };

            foreach (int expectedId in newIds)
            {
                BillInfo bill = GenerateRandomBillInfo(expectedId);
                bill.DueDate = duedates[expectedId];
                AddToDb(bill);
                bills.Add(bill);
            }

            SqliteDbBillReaderWriter sqliteReader = new SqliteDbBillReaderWriter(_connString);
            IList <BillInfo>         retBills     = sqliteReader.GetBillByFilter(
                bill => bill.DueDate >= new DateTime(1990, 10, 2) && bill.DueDate <= new DateTime(1990, 10, 3));

            Assert.AreEqual(retBills.Count, 2);
            Assert.AreEqual(retBills[0].Id, newIds[1]);
            Assert.AreEqual(retBills[1].Id, newIds[2]);
        }
        BillInfo GetBankContent.getBillInfo(string htmlBody)
        {
            BillInfo billInfo = new BillInfo();

            if (htmlBody.Contains("票据号码:"))
            {
                billInfo.BillNo = htmlBody.Substring(htmlBody.IndexOf("票据号码:") + 5, 34);
                billInfo.SueDt  = htmlBody.Substring(htmlBody.IndexOf("出票日期:") + 5, 10);
                billInfo.DueDt  = htmlBody.Substring(htmlBody.IndexOf("汇票到期日:") + 6, 10);

                //int billMoney = htmlBody.IndexOf("<td width=\"43 % \" class=\"rightLine v - binding\" rowspan=\"2\">");
                //int billMoneyEnd = htmlBody.IndexOf("</td>", billMoney + 60, 20);
                //billInfo.BillMoney = htmlBody.Substring(billMoney + 60, billMoneyEnd-billMoney-60);

                //int acceptor = htmlBody.IndexOf("<td width=\"73 % \" class=\"bottomLine v - binding\">&nbsp;");
                //int acceptorEnd = htmlBody.IndexOf("</td>", acceptor + 55, 20);
                //billInfo.Acceptor = htmlBody.Substring(acceptor + 55, acceptorEnd - acceptor - 55);

                //int remitter = htmlBody.IndexOf("<td width=\"237\" class=\"v - binding\">");
                //int remitterEnd = htmlBody.IndexOf("</td>", remitter + 34, 40);
                //billInfo.Remitter = htmlBody.Substring(remitter + 34, remitterEnd - remitter - 34);
            }
            else
            {
                return(null);
            }



            return(billInfo);
        }
Beispiel #24
0
        public void UpdateBillInfoTest()
        {
            BillInfo bill = billDefaults.returnBillInfoDefaults();

            var billRefInfo            = "123";
            var benChapterNo           = "chap 123";
            var benBranchNo            = "branch 123";
            var benSectionNo           = "sec 123";
            var benSequenceNo          = "sec 123";
            var benSubDepartmentsCount = "123";
            var benSubSectionsCount    = "section 123";
            var agencyCode             = "456";
            var displayLabelAr         = "disp Ar";
            var displayLabelEn         = "disp En";
            var sadadBatchId           = "sadad 123";


            bill.UpdateBillInfo(billRefInfo, benChapterNo, benBranchNo, benSectionNo, benSequenceNo,
                                benSubDepartmentsCount, benSubSectionsCount, agencyCode, displayLabelAr, displayLabelEn, sadadBatchId);

            bill.ShouldNotBeNull();
            bill.BillInvoiceNumber.ShouldBe(billRefInfo);
            bill.BillReferenceInfo.ShouldBe(billRefInfo);
            bill.BenChapterNumber.ShouldBe(benChapterNo);
            bill.BankBranchId.ShouldBe(benBranchNo);
            bill.BenSectionNumber.ShouldBe(benSectionNo);
            bill.BenSequenceNumber.ShouldBe(benSequenceNo);
            bill.BenSubDepartmentsCount.ShouldBe(benSubDepartmentsCount);
            bill.BenSubSectionsCount.ShouldBe(benSubSectionsCount);
            bill.AgencyCode.ShouldBe(agencyCode);
            bill.DisplayLabelAr.ShouldBe(displayLabelAr);
            bill.DisplayLabelEn.ShouldBeNull();
            bill.SadadBatchId.ShouldBe(sadadBatchId);
            bill.BillStatusId.ShouldBe((int)Enums.BillStatus.SuccessUploaded);
        }
Beispiel #25
0
        public List <BillInfo> GetBillInfos(string idBill)
        {
            List <BillInfo> billInfos = new List <BillInfo>();

            try
            {
                OpenConnection();
                string       queryString = "SELECT * FROM BillInfo WHERE idBill=" + idBill;
                MySqlCommand command     = new MySqlCommand(queryString, conn);
                command.ExecuteNonQuery();
                MySqlDataAdapter adapter   = new MySqlDataAdapter(command);
                DataTable        dataTable = new DataTable();
                adapter.Fill(dataTable);
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    BillInfo billInfo = new BillInfo(int.Parse(dataTable.Rows[i].ItemArray[0].ToString()),
                                                     int.Parse(dataTable.Rows[i].ItemArray[1].ToString()), int.Parse(dataTable.Rows[i].ItemArray[2].ToString()),
                                                     long.Parse(dataTable.Rows[i].ItemArray[3].ToString()));
                    billInfos.Add(billInfo);
                }
                return(billInfos);
            }
            catch
            {
                return(billInfos);
            }
            finally
            {
                CloseConnection();
            }
        }
Beispiel #26
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            HOA_DON         hd           = HOA_DON_BLL.Instance.getHOADONbyID(ID_HD);
            List <BillInfo> listtach     = new List <BillInfo>();
            int             dem          = 0;
            List <BillInfo> listbillInfo = BillInfo_BLL.Instance.GetList(Table_BLL.Instance.gettable((int)hd.ID_BAN));

            for (int i = 0; i < dtgDetail.Rows.Count - 1; i++)
            {
                BillInfo a = new BillInfo();
                a.MatHang = dtgDetail.Rows[i].Cells["Ten"].Value.ToString();

                if (Convert.ToInt32(dtgDetail.Rows[i].Cells["SL"].Value) < 0 || Convert.ToInt32(dtgDetail.Rows[i].Cells["SL"].Value) > listbillInfo[i].SoLuong)
                {
                    MessageBox.Show("So luong cua mon  " + a.MatHang.ToString() + " khong phu hop");
                    ++dem;
                }
                else
                {
                    a.SoLuong = Convert.ToInt32(dtgDetail.Rows[i].Cells["SL"].Value);
                    listtach.Add(a);
                }
            }
            if (dem == 0)
            {
                TableTach f = new TableTach((int)hd.ID_BAN, listtach, user);
                f.ShowDialog();
                this.Dispose();
            }
        }
Beispiel #27
0
        public int addOrder(Bill bill, List <Combo> listCombo, Account cus, ref string error)
        {
            foreach (Combo com in listCombo)
            {
                try
                {
                    Order order = new Order(1, com.Drink.Id, com.Drink.Price, com.Drink.Ghichu);
                    OrderDAO.Instance.insertOrder(order, ref error);
                    order = OrderDAO.Instance.getLastOrder();
                    BillInfo billInfo = new BillInfo(bill.Id, order.Id, com.Count);
                    BillInfoBUS.Instance.insertBillInfo(billInfo, ref error);
                    CartBUS.Instance.insertCart(new Cart(cus.Id, order.Id, com.Count, order.Ghichu), ref error);

                    foreach (Topping top in com.ListTopping)
                    {
                        AddInfo addInfo = new AddInfo(order.Id, top.Id, 1);
                        AddInfoBUS.Instance.insertAddInfo(addInfo, ref error);
                    }
                }
                catch (Exception ex)
                {
                    error = ex.Message;
                    return(0);
                }
            }
            return(1);
        }
Beispiel #28
0
        public bool Record(BillInfo bill, out string errorString)
        {
            if (string.IsNullOrEmpty(bill.BillName))
            {
                errorString = "Bill name cannot be null or empty";
                return(false);
            }

            Directory.CreateDirectory(_dataFolder);

            string filePath = $@".\{_dataFolder}\{bill.BillName}";

            if (File.Exists(filePath))
            {
                errorString = "Bill name is already existent. Please choose another name";
                return(false);
            }

            JsonSerializer jsonSerializer = GetConfiguredJsonSerializer();

            using (StreamWriter sw = new StreamWriter(filePath))
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    jsonSerializer.Serialize(writer, bill);
                }

            errorString = "";
            return(true);
        }
 private void InitializeBillInfo()
 {
     billInfo = new BillInfo();
     billInfo.Name = "Hanna Moos";
     billInfo.Date = DateTime.Today.Month + "/" + DateTime.Today.Day + "/" + DateTime.Today.Year;
     billInfo.Address = "German";
     billInfo.InvoiceNumber = "947823";
 }
 private void CompareDbBillWithExpectedBill(BillInfo expectedBill)
 {
     using (DataAccessLayer dbAccess2 = new DataAccessLayer(_connString))
     {
         dbAccess2.FindBillById(expectedBill.Id, out BillInfo actualBill);
         Assert.IsTrue(actualBill.SameData(expectedBill));
     }
 }
Beispiel #31
0
 private void InitializeBillInfo()
 {
     billInfo               = new BillInfo();
     billInfo.Name          = "Hanna Moos";
     billInfo.Date          = DateTime.Today.Month + "/" + DateTime.Today.Day + "/" + DateTime.Today.Year;
     billInfo.Address       = "German";
     billInfo.InvoiceNumber = "947823";
 }
        public static CheckStatusResult CheckBillStatus(string ServiceURL, bool IgnoreInvalidServerCertificate, long MerchantID, long TerminalID, long orderId, string RequestKey, BillInfo bInfo)
        {
            ServicePointManager.ServerCertificateValidationCallback = null;
            if (IgnoreInvalidServerCertificate)
                ServicePointManager.ServerCertificateValidationCallback =
                       new RemoteCertificateValidationCallback(ValidateServerCertificate);

            MerchantUtility cm = new MerchantUtility { Url = ServiceURL };
            CheckStatusResult Res = cm.CheckBillStatus(MerchantID.ToString(), TerminalID.ToString(), orderId, RequestKey, bInfo.BillID, bInfo.BillPaymentID);


            return Res;
        }