Пример #1
0
        public void TestEditReceipt()
        {
            ClientConnectionManager p = new ClientConnectionManager("127.0.0.1", 25565);

            Assert.IsTrue(p.ConnectToServer());

            p.InsertStock("Apple", 0.5, 1, 100);
            p.InsertStock("Orange", 0.7, 1.5, 100);
            p.InsertStock("Banana", 0.65, 1.2, 100);

            int lenReceipt = p.RequestStockInfo(-1).Count - 1;

            StockRecord aRecord = p.RequestStockInfo(-1)[lenReceipt];
            StockRecord bRecord = p.RequestStockInfo(-1)[lenReceipt - 1];
            StockRecord cRecord = p.RequestStockInfo(-1)[lenReceipt - 2];

            ItemSaleRecord a = new ItemSaleRecord(0, aRecord.StockID, 1, 1);
            ItemSaleRecord b = new ItemSaleRecord(0, bRecord.StockID, 1.5, 2);
            ItemSaleRecord c = new ItemSaleRecord(0, cRecord.StockID, 1.2, 1);


            List <ItemSaleRecord> s = new List <ItemSaleRecord>();

            s.Add(a);
            s.Add(b);
            s.Add(c);

            Assert.IsTrue(p.InsertReceipt(s));

            int lenReceiptNew = p.RequestReceiptInfo(-1).Count - 1;

            ReceiptRecord aReceipt = (ReceiptRecord)p.RequestReceiptInfo(-1)[lenReceiptNew];

            Assert.IsTrue(p.UpdateReceipt(aReceipt.SaleID));
        }
Пример #2
0
 private void btn_requestReceipt_Click(object sender, EventArgs e)
 {
     if (txt_receiptRequestBox.Text != "")
     {
         if ((recordList = _connection.RequestReceiptInfo(int.Parse(txt_receiptRequestBox.Text))) != null)
         {
             txt_requestReceiptName.Text = ((ItemSaleRecord)recordList[0]).Name;
             txt_requestReceiptQty.Text  = ((ItemSaleRecord)recordList[0]).Quantity.ToString();
             txt_requestReceiptSell.Text = ((ItemSaleRecord)recordList[0]).PriceSold.ToString();
             txt_requestReceiptNo.Text   = "0";
         }
     }
     else
     {
         if ((recordList = _connection.RequestReceiptInfo()) != null)
         {
             txt_requestReceiptDate.Text = ((ReceiptRecord)recordList[0]).Date.ToString();
             txt_requestReceiptID.Text   = ((ReceiptRecord)recordList[0]).SaleID.ToString();
         }
     }
 }
Пример #3
0
        public void TestAddReceipt()
        {
            ClientConnectionManager p = new ClientConnectionManager("127.0.0.1", 25565);

            Assert.IsTrue(p.ConnectToServer());

            p.DeleteReceipt(-1);
            p.DeleteStock(-1);

            p.InsertStock("Apple", 0.5, 1, 100);
            p.InsertStock("Orange", 0.7, 1.5, 100);
            p.InsertStock("Banana", 0.65, 1.2, 100);

            int lenStock = p.RequestStockInfo(-1).Count - 1;

            List <StockRecord> records = p.RequestStockInfo(-1);
            StockRecord        aRecord = records[lenStock];
            StockRecord        bRecord = records[lenStock - 1];
            StockRecord        cRecord = records[lenStock - 2];

            ItemSaleRecord a = new ItemSaleRecord(0, aRecord.StockID, 1, 1);
            ItemSaleRecord b = new ItemSaleRecord(0, bRecord.StockID, 1.5, 2);
            ItemSaleRecord c = new ItemSaleRecord(0, cRecord.StockID, 1.2, 1);


            List <ItemSaleRecord> s = new List <ItemSaleRecord>();

            s.Add(a);
            s.Add(b);
            s.Add(c);

            Assert.IsTrue(p.InsertReceipt(s));


            int lenReceiptNew = p.RequestReceiptInfo(-1).Count - 1;

            //ReceiptRecord lastReceipt = (ReceiptRecord)p.RequestReceiptInfo(-1)[lenReceiptNew];
            Assert.IsTrue(p.RequestReceiptInfo(-1).Count == 1);
        }