Example #1
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textDatePlaced.errorProvider1.GetError(textDatePlaced) != "" ||
         textAmountTotal.errorProvider1.GetError(textAmountTotal) != "" ||
         textShippingCharge.errorProvider1.GetError(textShippingCharge) != "" ||
         !textDateReceived.IsValid)
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textDatePlaced.Text == "")
     {
         SupplyOrderCur.DatePlaced = new DateTime(2500, 1, 1);
         SupplyOrderCur.UserNum    = 0;           //even if they had set a user, set it back because the order hasn't been placed.
     }
     else
     {
         SupplyOrderCur.DatePlaced = PIn.Date(textDatePlaced.Text);
         SupplyOrderCur.UserNum    = comboUser.GetSelectedKey <Userod>(x => x.UserNum);
     }
     SupplyOrderCur.AmountTotal    = PIn.Double(textAmountTotal.Text);
     SupplyOrderCur.Note           = textNote.Text;
     SupplyOrderCur.ShippingCharge = PIn.Double(textShippingCharge.Text);
     SupplyOrderCur.DateReceived   = PIn.Date(textDateReceived.Text);
     SupplyOrders.Update(SupplyOrderCur);            //never new
     DialogResult = DialogResult.OK;
 }
Example #2
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textDatePlaced.errorProvider1.GetError(textDatePlaced) != "" ||
         textAmountTotal.errorProvider1.GetError(textAmountTotal) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textDatePlaced.Text == "")
     {
         Order.DatePlaced = new DateTime(2500, 1, 1);
     }
     else
     {
         Order.DatePlaced = PIn.Date(textDatePlaced.Text);
     }
     Order.AmountTotal = PIn.Double(textAmountTotal.Text);
     Order.Note        = textNote.Text;
     SupplyOrders.Update(Order);            //never new
     DialogResult = DialogResult.OK;
 }
Example #3
0
        private void FillGridOrderItem()
        {
            long orderNum = 0;

            if (gridOrders.GetSelectedIndex() != -1)           //an order is selected
            {
                orderNum = _listOrders[gridOrders.GetSelectedIndex()].SupplyOrderNum;
            }
            _tableOrderItems = SupplyOrderItems.GetItemsForOrder(orderNum);
            gridItems.BeginUpdate();
            gridItems.Columns.Clear();
            //ODGridColumn col=new ODGridColumn(Lan.g(this,"Supplier"),120);
            //gridItems.Columns.Add(col);
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Catalog #"), 80);

            gridItems.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Description"), 320);
            gridItems.Columns.Add(col);
            col            = new ODGridColumn(Lan.g(this, "Qty"), 60, HorizontalAlignment.Center);
            col.IsEditable = true;
            gridItems.Columns.Add(col);
            col            = new ODGridColumn(Lan.g(this, "Price/Unit"), 70, HorizontalAlignment.Right);
            col.IsEditable = true;
            gridItems.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Subtotal"), 70, HorizontalAlignment.Right);
            gridItems.Columns.Add(col);
            gridItems.Rows.Clear();
            ODGridRow row;
            double    price;
            int       qty;
            double    subtotal;
            double    total         = 0;
            bool      autocalcTotal = true;

            for (int i = 0; i < _tableOrderItems.Rows.Count; i++)
            {
                row = new ODGridRow();
                //if(gridOrders.GetSelectedIndex()==-1){
                //	row.Cells.Add("");
                //}
                //else{
                //	row.Cells.Add(Suppliers.GetName(ListSuppliers,ListOrders[gridOrders.GetSelectedIndex()].SupplierNum));
                //}
                row.Cells.Add(_tableOrderItems.Rows[i]["CatalogNumber"].ToString());
                row.Cells.Add(_tableOrderItems.Rows[i]["Descript"].ToString());
                qty = PIn.Int(_tableOrderItems.Rows[i]["Qty"].ToString());
                row.Cells.Add(qty.ToString());
                price = PIn.Double(_tableOrderItems.Rows[i]["Price"].ToString());
                row.Cells.Add(price.ToString("n"));
                subtotal = ((double)qty) * price;
                row.Cells.Add(subtotal.ToString("n"));
                gridItems.Rows.Add(row);
                if (subtotal == 0)
                {
                    autocalcTotal = false;
                }
                total += subtotal;
            }
            gridItems.EndUpdate();
            if (gridOrders.GetSelectedIndex() != -1 &&
                autocalcTotal &&
                total != _listOrders[gridOrders.GetSelectedIndex()].AmountTotal)
            {
                SupplyOrder order = _listOrders[gridOrders.GetSelectedIndex()].Copy();
                order.AmountTotal = total;
                SupplyOrders.Update(order);
                FillGridOrders();
                for (int i = 0; i < _listOrders.Count; i++)
                {
                    if (_listOrders[i].SupplyOrderNum == order.SupplyOrderNum)
                    {
                        gridOrders.SetSelected(i, true);
                    }
                }
            }
        }