Ejemplo n.º 1
0
        public void Add100ItemsToRegisterAndChange1Price100Times()
        {
            // setup
            Register r = new Register();

            for (int i = 0; i < 100; i++)
            {
                var s1 = new SoldLineItem();
                // create a sale item
                s1.ItemID = TestInventoryItem;
                s1.Price = TestPrice * i;
                s1.Quantity = TestQuantity * i;
                s1.Description = TestDescription;

                // trigger
                r.Add(s1);
                s1 = null;
            }

            for (int i = 5; i < 55; i++)
            {
                r.Update(i, 23.4, 3);
            }

            for (int i = 45; i < 60; i++)
            {
                r.DeleteRow(i);
            }

            double subTotal = r.SubTotal();
            // validate
            int registerCount = r.RegisterCount();
            Assert.AreEqual(registerCount, 85, "expected register to have only 85 items");
            Assert.AreEqual(277765.14999999997, subTotal, "expected different subtotal");
        }
Ejemplo n.º 2
0
        public void AddItemRemoveItem()
        {
            // setup
            Register r = new Register();
            var s1 = new SoldLineItem();

            // create a sale item
            s1.ItemID = TestInventoryItem;
            s1.Price = TestPrice;
            s1.Quantity = TestQuantity;
            s1.Description = TestDescription;

            // trigger
            r.Add(s1);
            var registerLine = new SoldLineItem();

            registerLine = r.GetOneLine(0);
            // validate
            Assert.AreSame(TestDescription, registerLine.Description, "expected same descriptions");
            Assert.AreEqual(TestInventoryItem, registerLine.ItemID, "expected same inventory item id");
            Assert.AreEqual(TestPrice, registerLine.Price, "expected same price");
            Assert.AreEqual(TestQuantity, registerLine.Quantity, "expected same quantity");
            Assert.AreEqual((TestPrice * TestQuantity), registerLine.Extended, "expected same extension");
            Assert.AreEqual(0, registerLine.LineItemID, "expected first line item");
        }
Ejemplo n.º 3
0
 public void LoadControl(SoldLineItem li)
 {
     this.lblLineItem.Text = li.LineItemID.ToString();
     this.txtItemID.Text = li.ItemID.ToString();
     this.txtDescription.Text = li.Description;
     this.txtPrice.Text = li.Price.ToString("c");
     this.txtQuantity.Text = li.Quantity.ToString();
     this.txtExtended.Text = li.Extended.ToString("c");
     UserControlLineItemID = int.Parse(li.LineItemID.ToString());
 }
Ejemplo n.º 4
0
 public SoldLineItem GetOneLine(int RowID)
 {
     SoldLineItem candidate = new SoldLineItem();
     foreach (SoldLineItem item in Sale)
     {
         if (item.LineItemID == RowID)
         {
             candidate = item;
         }
     }
     return candidate;
 }
Ejemplo n.º 5
0
        public void DeleteRow(int RowID)
        {
            SoldLineItem removeCandidate = new SoldLineItem();
            Sale.RemoveAt(RowID);

            // now reindex the rest of the line items
            foreach (SoldLineItem item in this.Sale)
            {
                if (item.LineItemID > RowID)
                {
                    item.LineItemID--;
                }
            }
        }
Ejemplo n.º 6
0
        private bool DuplicateCheck(SoldLineItem check)
        {
            bool bReturn = false;
            foreach (SoldLineItem item in TheSale.Sale)
            {
                if (item.ItemID == check.ItemID)
                {
                    if (item.ItemID == 101010101)
                    {
                        bReturn = false;
                    }
                    else
                    {
                        bReturn = true;
                    }
                }
            }

            return bReturn;
        }
Ejemplo n.º 7
0
        private SoldLineItem BarCodeScan(int ItemID)
        {
            SoldLineItem returnitem = new SoldLineItem();

                    SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DoubleTake"].ToString());
                    SqlCommand cmd = new SqlCommand("dtuser.UnSoldItemID_Select");
                    SqlDataReader dr;
                    cmd.CommandType = CommandType.StoredProcedure;

                    try
                    {
                        cn.Open();
                        cmd.Connection = cn;
                        cmd.Parameters.Add("@pItemID", SqlDbType.Int).Value = ItemID;

                        dr = cmd.ExecuteReader();

                        if (dr.HasRows == true)
                        {
                            while (dr.Read())
                            {
                                returnitem.LineItemID = LineItem;
                                returnitem.ItemID = dr.GetSqlInt32(0).Value;
                                returnitem.Description = dr.GetSqlValue(1).ToString();
                                returnitem.Price = (double)dr.GetSqlMoney(2).Value;
                                returnitem.Quantity = 1;
                                returnitem.Extended = (double)dr.GetSqlMoney(2).Value;
                             }
                            return returnitem;

                        }
                        else
                        {
                            MessageBox.Show("No Inventory Found With that Search", "Search", MessageBoxButtons.OK);
                            return null;
                        }

                    }
                    catch (SqlException sx)
                    {
                        MessageBox.Show(sx.Message.ToString(), "SQL Data Error", MessageBoxButtons.OK);
                        return null;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString(), "C# Error", MessageBoxButtons.OK);
                        return null;
                    }
                    finally
                    {
                        if (cn.State != ConnectionState.Closed)
                        {
                            cn.Close();
                        }
                    }
        }
Ejemplo n.º 8
0
        public void AddOneItemToRegister()
        {
            // setup
            Register r = new Register();
            var s1 = new SoldLineItem();

            // create a sale item
            s1.ItemID = TestInventoryItem;
            s1.Price = TestPrice;
            s1.Quantity = TestQuantity;
            s1.Description = TestDescription;

            // trigger
            r.Add(s1);

            // validate
            int registerCount = r.RegisterCount();
            double extended = s1.Extended;
            double subTotal = r.SubTotal();
            Assert.AreEqual(registerCount, 1, "expected register to have only 1 item");
            Assert.AreEqual(ExpectedSubtotal, subTotal, "expected different subtotal for 1 item");
            Assert.AreEqual(ExpectedExtended, extended, "expected different subtotal for 1 item");
        }
Ejemplo n.º 9
0
        public void RemoveFirstItem()
        {
            // setup
            Register r = new Register();

            for (int i = 0; i < 3; i++)
            {
                var s1 = new SoldLineItem();

                // create a sale item
                s1.LineItemID = i;
                s1.ItemID = TestInventoryItem;
                s1.Price = TestPrice;
                s1.Quantity = TestQuantity;
                s1.Description = TestDescription;

                // trigger
                r.Add(s1);
            }

            r.DeleteRow(0);

            Assert.AreEqual(r.RegisterCount(), 2, "expected 2 items");
            Assert.AreEqual(r.Sale[0].LineItemID, 0, "expected first item 0");
            Assert.AreEqual(r.Sale[1].LineItemID, 1, "expected second item 2");
        }
Ejemplo n.º 10
0
        public void AddTwoRemoveOneAddAgainUpdateLast()
        {
            // setup
            Register r = new Register();

            for (int i = 0; i < 2; i++)
            {
                var s1 = new SoldLineItem();

                // create a sale item
                s1.LineItemID = i;
                s1.ItemID = TestInventoryItem;
                s1.Price = i;
                s1.Quantity = i;
                s1.Description = TestDescription;

                // trigger
                r.Add(s1);
            }
            int removeIndex = r.RegisterCount();
            r.DeleteRow(removeIndex -1);

            var s2 = new SoldLineItem();

            // create a sale item
            s2.LineItemID = 3;
            s2.ItemID = TestInventoryItem;
            s2.Price = 3;
            s2.Quantity = 3;
            s2.Description = TestDescription;
            r.Add(s2);

            r.Update(2, 5, 5);
            Assert.AreEqual(r.RegisterCount(), 2, "expected 2 items");
            Assert.AreEqual(r.Sale[0].LineItemID, 0, "expected 0 for first");
            Assert.AreEqual(r.Sale[1].LineItemID, 3, "expected 3 for last");
        }
Ejemplo n.º 11
0
        public void AddTenItemsToRegister()
        {
            // setup
            Register r = new Register();
            for (int i = 0; i < 10; i++)
            {
                var s1 = new SoldLineItem();

                // create a sale item
                s1.Description = TestDescription;
                s1.ItemID = TestInventoryItem;
                s1.Price = TestPrice;
                s1.Quantity = TestQuantity;

                // trigger
                r.Add(s1);
                s1 = null;
            }

            // validate
            int registerCount = r.RegisterCount();
            double subTotal = r.SubTotal();
            Assert.AreEqual(registerCount, 10, "expected register to have only 10 items");
            Assert.AreEqual(subTotal, 10.1, "expected different subtotal for 10 item");
        }
Ejemplo n.º 12
0
        public void AddOneThousandDifferentItemsToRegister()
        {
            // setup
            Register r = new Register();
            for (int i = 0; i < 1000; i++)
            {
                var s1 = new SoldLineItem();

                // create a sale item
                s1.ItemID = TestInventoryItem;
                s1.Price = TestPrice * i;
                s1.Quantity = TestQuantity * i;

                // trigger
                r.Add(s1);
                s1 = null;
            }

            // validate
            int registerCount = r.RegisterCount();
            double subTotal = r.SubTotal();
            Assert.AreEqual(registerCount, 1000, "expected register to have only 10 items");
            Assert.AreEqual(subTotal, 336161835.0, "expected different subtotal for 10 item");
        }
Ejemplo n.º 13
0
 public void Add(SoldLineItem _lineitem)
 {
     Sale.Add(_lineitem);
 }
Ejemplo n.º 14
0
        private bool DuplicateCheck(SoldLineItem check)
        {
            bool bReturn = false;
            try
            {
                foreach (SoldLineItem item in TheSale.Sale)
                {
                    if (item.ItemID == check.ItemID)
                    {
                        if (item.ItemID == 101010101)
                        {
                            bReturn = false;
                        }
                        else
                        {
                            bReturn = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Exception at DuplicateCheck: {0}", ex));
            }

            return bReturn;
        }