コード例 #1
0
ファイル: PurchaseOrders.cs プロジェクト: NathanDurst2/IST465
        private void dataSelected_CellEndEdit(object sender, EventArgs e)
        {
            try
            {
                string itemNumber   = (string)dataSelected.Rows[dataSelected.CurrentCell.RowIndex].Cells["sItem"].Value;
                double itemCost     = Convert.ToDouble(dataSelected.Rows[dataSelected.CurrentCell.RowIndex].Cells["sCost"].Value);
                int    itemQuantity = Convert.ToInt32(dataSelected.Rows[dataSelected.CurrentCell.RowIndex].Cells["sQuantity"].Value);
                int    dataIndex    = dataSelected.CurrentCell.RowIndex;

                PurchaseOrder_Item si = new PurchaseOrder_Item();
                si.Item_Number   = itemNumber;
                si.Item_Quantity = itemQuantity;
                si.Item_Cost     = itemCost;


                selected.RemoveAt(dataIndex);
                selected.Insert(dataIndex, si);

                double costed = 0;
                foreach (PurchaseOrder_Item poi in selected)
                {
                    costed += poi.Item_Cost * poi.Item_Quantity;
                }
                tbSubTotal.Text  = String.Format("$ " + Math.Round(costed, 2));
                tbTotalCost.Text = String.Format("$ " + Math.Round(costed * (1 + taxRate), 2));
                cost             = costed;
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid value entered - please try again");
                dataSelected.CurrentCell.Value = 0;
            }
        }
コード例 #2
0
 public static void AddPurchaseOrder_Item(PurchaseOrder_Item c)
 {
     using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
     {
         cnn.Execute("insert into PurchaseOrder_Item (PO_ID, Item_Number, Item_Quantity, Item_Cost) values (@PO_ID, @Item_Number, @Item_Quantity, @Item_Cost)", c);
     }
 }
コード例 #3
0
ファイル: PurchaseOrders.cs プロジェクト: NathanDurst2/IST465
        private void BtAdd_Click(object sender, EventArgs e)
        {
            if (dataAll.CurrentCell != null)
            {
                string itemNumber = (string)dataAll.Rows[dataAll.CurrentCell.RowIndex].Cells["allItems"].Value;

                dataSelected.Rows.Add();
                dataSelected.Rows[dataSelected.RowCount - 1].Cells["sItem"].Value = itemNumber;
                dataSelected.Rows[dataSelected.RowCount - 1].Cells["sCost"].Value = SqliteDataAccess.LoadItem(itemNumber)[0].Item_PurchasePrice;

                dataAll.Rows.RemoveAt(dataAll.CurrentCell.RowIndex);


                PurchaseOrder_Item si = new PurchaseOrder_Item();
                si.Item_Number = itemNumber;
                si.Item_Cost   = SqliteDataAccess.LoadItem(itemNumber)[0].Item_PurchasePrice;
                selected.Add(si);


                dataSelected.CurrentCell       = dataSelected.Rows[dataSelected.Rows.Count - 1].Cells["sQuantity"];
                dataSelected.CurrentCell.Value = 0;
                dataSelected.BeginEdit(true);
                //tbSubTotal.Text = String.Format("$ " + Math.Round(cost, 2));
                //tbTotalCost.Text = String.Format("$ " + Math.Round((cost * (1 + taxRate)), 2));
            }
            else
            {
                MessageBox.Show("Please select a row and try again");
            }
        }