public ActionResult Save(SupplyOrder model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             var allErrors = ModelState.Values.SelectMany(v => v.Errors);
         }
         else
         {
             model.OrganizationId = OrganizationId;
             model.CreatedDate    = System.DateTime.Now;
             model.CreatedBy      = UserID.ToString();
             string referenceNo = new SupplyOrderRepository().InsertSupplyOrder(model);
             if (referenceNo != "")
             {
                 TempData["error"]   = "";
                 TempData["success"] = "Saved successfully. Reference No. is " + referenceNo;
                 return(RedirectToAction("PendingSupplyOrder"));
             }
             else
             {
                 TempData["error"]   = "Some error occured while saving. Please try again.";
                 TempData["success"] = "";
             }
         }
     }
     catch (Exception)
     {
         TempData["error"]   = "Some error occured. Please try again.";
         TempData["success"] = "";
     }
     FillDropdowns();
     return(View("Create", model));
 }
        public async Task <IActionResult> Create(int[] SelectedSuppliers, [Bind("ProductID,SKU,ProductName,Price,ProductDescription")] Product product)
        {
            if (ModelState.IsValid)
            {
                //Generate next SKU
                product.SKU = GenerateSKU.GetNextSKU(_context);

                _context.Add(product);
                await _context.SaveChangesAsync();

                //add connections to suppliers
                //first, find the course you just added
                Product dbProduct = _context.Products.FirstOrDefault(c => c.SKU == product.SKU);

                //loop through selected Supplier and add them
                foreach (int i in SelectedSuppliers)
                {
                    Supplier    dbSupp = _context.Suppliers.Find(i);
                    SupplyOrder so     = new SupplyOrder
                    {
                        Product  = dbProduct,
                        Supplier = dbSupp
                    };
                    _context.SupplyOrders.Add(so);
                    _context.SaveChanges();
                }
                return(RedirectToAction(nameof(Index)));
            }
            //re-populate the viewbag
            ViewBag.AllSuppliers = GetAllSuppliers();
            return(View(product));
        }
Example #3
0
 private void PayButton_Click(object sender, RoutedEventArgs e)
 {
     if (_selectedOrders.Any())
     {
         var result = MessageBox.Show("Confirm payment", "Confirm", MessageBoxButton.OKCancel,
                                      MessageBoxImage.Question);
         if (result == MessageBoxResult.Cancel)
         {
             return;
         }
         if (SupplyOrder.PaySupplyOrders(_selectedOrders))
         {
             MessageBox.Show("Successfully Updated!!", "Information", MessageBoxButton.OK,
                             MessageBoxImage.Information);
             RefreshDataGrid();
         }
         else
         {
             MessageBox.Show("Not Updated", "Error", MessageBoxButton.OK,
                             MessageBoxImage.Error);
         }
     }
     else
     {
         MessageBox.Show("Please Select supply orders", "Nothing Selected", MessageBoxButton.OK,
                         MessageBoxImage.Information);
     }
 }
Example #4
0
        ///<summary>Inserts one SupplyOrder into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(SupplyOrder supplyOrder, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                supplyOrder.SupplyOrderNum = ReplicationServers.GetKey("supplyorder", "SupplyOrderNum");
            }
            string command = "INSERT INTO supplyorder (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "SupplyOrderNum,";
            }
            command += "SupplierNum,DatePlaced,Note,AmountTotal) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(supplyOrder.SupplyOrderNum) + ",";
            }
            command +=
                POut.Long(supplyOrder.SupplierNum) + ","
                + POut.Date(supplyOrder.DatePlaced) + ","
                + "'" + POut.String(supplyOrder.Note) + "',"
                + "'" + POut.Double(supplyOrder.AmountTotal) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                supplyOrder.SupplyOrderNum = Db.NonQ(command, true);
            }
            return(supplyOrder.SupplyOrderNum);
        }
Example #5
0
        private void butNewOrder_Click(object sender, EventArgs e)
        {
            if (comboSupplier.IsAllSelected)
            {
                MsgBox.Show(this, "Please select a supplier first.");
                return;
            }
            for (int i = 0; i < _listSupplyOrders.Count; i++)
            {
                if (_listSupplyOrders[i].DatePlaced.Year > 2200)
                {
                    MsgBox.Show(this, "Not allowed to add a new order when there is already one pending.  Please finish the other order instead.");
                    return;
                }
            }
            SupplyOrder order = new SupplyOrder();

            if (comboSupplier.IsAllSelected)
            {
                order.SupplierNum = 0;
            }
            else              //Specific supplier selected.
            {
                order.SupplierNum = comboSupplier.GetSelectedKey <Supplier>(x => x.SupplierNum);
            }
            order.IsNew      = true;
            order.DatePlaced = new DateTime(2300, 1, 1);
            order.Note       = "";
            order.UserNum    = 0;       //This will get set when the order is placed.
            SupplyOrders.Insert(order);
            FillGridOrders();
            gridOrders.SetSelected(_listSupplyOrders.Count - 1, true);
            gridOrders.ScrollToEnd();
            FillGridOrderItem();
        }
Example #6
0
 ///<summary>Inserts one SupplyOrder into the database.  Returns the new priKey.</summary>
 internal static long Insert(SupplyOrder supplyOrder)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         supplyOrder.SupplyOrderNum=DbHelper.GetNextOracleKey("supplyorder","SupplyOrderNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(supplyOrder,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     supplyOrder.SupplyOrderNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(supplyOrder,false);
     }
 }
Example #7
0
 ///<summary>Inserts one SupplyOrder into the database.  Returns the new priKey.</summary>
 internal static long Insert(SupplyOrder supplyOrder)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         supplyOrder.SupplyOrderNum = DbHelper.GetNextOracleKey("supplyorder", "SupplyOrderNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(supplyOrder, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     supplyOrder.SupplyOrderNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(supplyOrder, false));
     }
 }
Example #8
0
		///<summary>Inserts one SupplyOrder into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(SupplyOrder supplyOrder,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				supplyOrder.SupplyOrderNum=ReplicationServers.GetKey("supplyorder","SupplyOrderNum");
			}
			string command="INSERT INTO supplyorder (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="SupplyOrderNum,";
			}
			command+="SupplierNum,DatePlaced,Note,AmountTotal) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(supplyOrder.SupplyOrderNum)+",";
			}
			command+=
				     POut.Long  (supplyOrder.SupplierNum)+","
				+    POut.Date  (supplyOrder.DatePlaced)+","
				+"'"+POut.String(supplyOrder.Note)+"',"
				+"'"+POut.Double(supplyOrder.AmountTotal)+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				supplyOrder.SupplyOrderNum=Db.NonQ(command,true);
			}
			return supplyOrder.SupplyOrderNum;
		}
Example #9
0
 /// <summary>Creates a new order with all the items currently highlighted as a new pending order.</summary>
 private void butCreateOrders_Click(object sender,EventArgs e)
 {
     //Not visible in IsSelectMode
     if(gridMain.SelectedIndices.Length==0){
         MsgBox.Show(this,"Please select supplies, first.");
         return;
     }
     //they are not ordered by supplier, so we need to keep track of a local list of orders
     List<SupplyOrder> listSupplyOrders=new List<SupplyOrder>();
     SupplyOrder supplyOrder=null;
     for(int i=0;i<gridMain.SelectedIndices.Length;i++){
         supplyOrder=listSupplyOrders.FirstOrDefault(x=>x.SupplierNum==_listSupplies[gridMain.SelectedIndices[i]].SupplierNum);
         if(supplyOrder==null){
             supplyOrder=new SupplyOrder();
             supplyOrder.SupplierNum=_listSupplies[gridMain.SelectedIndices[i]].SupplierNum;
             supplyOrder.IsNew=true;
             supplyOrder.DatePlaced=new DateTime(2500,1,1); //date used for new 'pending' orders.
             supplyOrder.Note="";
             supplyOrder.UserNum=Security.CurUser.UserNum;
             supplyOrder.SupplyOrderNum=SupplyOrders.Insert(supplyOrder);
             listSupplyOrders.Add(supplyOrder);
         }
         SupplyOrderItem supplyOrderItem=new SupplyOrderItem();
         supplyOrderItem.SupplyNum=_listSupplies[gridMain.SelectedIndices[i]].SupplyNum;
         supplyOrderItem.Qty=_listSupplies[gridMain.SelectedIndices[i]].OrderQty;
         supplyOrderItem.Price=_listSupplies[gridMain.SelectedIndices[i]].Price;
         supplyOrderItem.SupplyOrderNum=supplyOrder.SupplyOrderNum;
         SupplyOrderItems.Insert(supplyOrderItem);
     }
     for(int i=0;i<listSupplyOrders.Count;i++){
         SupplyOrders.UpdateOrderPrice(listSupplyOrders[i].SupplyOrderNum);
     }
     MessageBox.Show(Lan.g(this,"Done. Added ")+listSupplyOrders.Count.ToString()+Lan.g(this," orders.  Manage orders from Orders window"));
     DialogResult=DialogResult.OK;
 }
Example #10
0
        private void butNewOrder_Click(object sender, EventArgs e)
        {
            if (comboSupplier.SelectedIndex < 1)             //Includes no items or the ALL supplier being selected.
            {
                MsgBox.Show(this, "Please select a supplier first.");
                return;
            }
            for (int i = 0; i < _listOrders.Count; i++)
            {
                if (_listOrders[i].DatePlaced.Year > 2200)
                {
                    MsgBox.Show(this, "Not allowed to add a new order when there is already one pending.  Please finish the other order instead.");
                    return;
                }
            }
            SupplyOrder order = new SupplyOrder();

            if (comboSupplier.SelectedIndex == 0)           //Supplier "All".
            {
                order.SupplierNum = 0;
            }
            else                                                                                 //Specific supplier selected.
            {
                order.SupplierNum = _listSuppliers[comboSupplier.SelectedIndex - 1].SupplierNum; //SelectedIndex-1 because "All" is first option.
            }
            order.IsNew      = true;
            order.DatePlaced = new DateTime(2500, 1, 1);
            order.Note       = "";
            SupplyOrders.Insert(order);
            _listOrdersAll = SupplyOrders.GetAll();          //Refresh the list all.
            FillGridOrders();
            gridOrders.SetSelected(_listOrders.Count - 1, true);
            gridOrders.ScrollToEnd();
            FillGridOrderItem();
        }
Example #11
0
        public async Task <int> SendSupplyOrderToServer(SupplyOrder order, Code code, Number num)
        {
            lock (thisLock)
            {
                try
                {
                    if (DataAccess.InDataProvider.Database.Connection.State != System.Data.ConnectionState.Open)
                    {
                        DataAccess.InDataProvider.Database.Connection.Open();
                    }
                    Logger.Info($"recive order {order.OrderId} | {code} | {num}");
                    if (code != null)
                    {
                        order.Code = code;
                    }
                    else
                    {
                        order.Code = DataAccess.InDataProvider.Codes.FirstOrDefault();
                    }
                    if (num != null)
                    {
                        order.Number = num;
                    }

                    DataAccess.InDataProvider.SupplyOrder.AddOrUpdate(order);
                    return(DataAccess.InDataProvider.SaveChanges());
                }
                catch (Exception ex)
                {
                    Logger.Info(ex.Message + "||" + ex.InnerException.Message);
                    tokenSource.Cancel();
                }
            }
            return(0);
        }
 ///<summary>Returns true if Update(SupplyOrder,SupplyOrder) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(SupplyOrder supplyOrder, SupplyOrder oldSupplyOrder)
 {
     if (supplyOrder.SupplierNum != oldSupplyOrder.SupplierNum)
     {
         return(true);
     }
     if (supplyOrder.DatePlaced.Date != oldSupplyOrder.DatePlaced.Date)
     {
         return(true);
     }
     if (supplyOrder.Note != oldSupplyOrder.Note)
     {
         return(true);
     }
     if (supplyOrder.AmountTotal != oldSupplyOrder.AmountTotal)
     {
         return(true);
     }
     if (supplyOrder.UserNum != oldSupplyOrder.UserNum)
     {
         return(true);
     }
     if (supplyOrder.ShippingCharge != oldSupplyOrder.ShippingCharge)
     {
         return(true);
     }
     if (supplyOrder.DateReceived.Date != oldSupplyOrder.DateReceived.Date)
     {
         return(true);
     }
     return(false);
 }
        public ActionResult Create(IList <PendingPurchaseRequest> PendingPurchaseRequestItemsSelected)
        {
            FillDropdowns();

            SupplyOrder supplyorder = new SupplyOrder();

            supplyorder.SupplyOrderNo = DatabaseCommonRepository.GetNextDocNo(9, OrganizationId);

            SupplyOrderRepository rep = new SupplyOrderRepository();

            if (PendingPurchaseRequestItemsSelected != null)
            {
                if (PendingPurchaseRequestItemsSelected.Count > 0)
                {
                    List <int> selectedpurchaserequests = (from PendingPurchaseRequest p in PendingPurchaseRequestItemsSelected
                                                           where p.Select
                                                           select p.PurchaseRequestId).ToList <int>();
                    supplyorder.SupplyOrderItems = rep.GetPurchaseRequestItems(selectedpurchaserequests, OrganizationId);
                }
            }
            supplyorder.SupplyOrderDate = System.DateTime.Today;
            supplyorder.RequiredDate    = System.DateTime.Today;
            supplyorder.CurrencyId      = new CurrencyRepository().GetCurrencyFrmOrganization(OrganizationId).CurrencyId;
            return(View(supplyorder));
        }
Example #14
0
        private void OnFinishOrderRequest(FuelSupplyManager.FinishOrder.ReceivedRequest request)
        {
            var newOrder = new SupplyOrder {
                Type = SupplyOrderType.None
            };

            var manager = writer.Data;

            var order = request.Payload;

            // TODO:result check
            if (manager.SupplyOrders.ContainsKey(order.SelfId))
            {
                var plan = manager.SupplyOrders[order.SelfId];
                plan.Orders.RemoveAll(o => o.Equals(order));

                if (plan.Orders.Count > 0)
                {
                    newOrder.Type = plan.Orders[0].Type;
                }
                else
                {
                    manager.SupplyOrders.Remove(order.SelfId);
                    manager.FreeSupplyers.Add(order.SelfId);
                }
            }

            commandReceiver.SendFinishOrderResponse(new FuelSupplyManager.FinishOrder.Response(request.RequestId, newOrder));

            writer.SendUpdate(new FuelSupplyManager.Update()
            {
                SupplyOrders  = manager.SupplyOrders,
                FreeSupplyers = manager.FreeSupplyers,
            });
        }
Example #15
0
        public string InsertSODT(SupplyOrder objSupplyOrder)
        {
            int id = 0;

            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                IDbTransaction trn = connection.BeginTransaction();
                try
                {
                    var supplyorderitemrepo = new SupplyOrderItemRepository();
                    foreach (var item in objSupplyOrder.SupplyOrderItems)
                    {
                        if (item.OrderedQty > 0)
                        {
                            item.SupplyOrderId  = objSupplyOrder.SupplyOrderId;
                            item.OrganizationId = objSupplyOrder.OrganizationId;
                            supplyorderitemrepo.InsertSupplyOrderItem(item, connection, trn);
                        }
                    }
                    InsertLoginHistory(dataConnection, objSupplyOrder.CreatedBy, "Update", "LPO", id.ToString(), "0");
                    trn.Commit();
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    trn.Rollback();
                    throw;
                }
                return(objSupplyOrder.SupplyOrderNo);
            }
        }
Example #16
0
        private void butNewOrder_Click(object sender, EventArgs e)
        {
            if (listSupplier.Count == 0)
            {
                MsgBox.Show(this, "Please add suppliers first.  Use the menu at the top of this window.");
                return;
            }
            if (comboSupplier.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a supplier first.");
                return;
            }
            for (int i = 0; i < listOrder.Count; i++)
            {
                if (listOrder[i].DatePlaced.Year > 2200)
                {
                    MsgBox.Show(this, "Not allowed to add a new order when there is already one pending.  Please finish the other order instead.");
                    return;
                }
            }
            SupplyOrder order = new SupplyOrder();

            order.SupplierNum = listSupplier[comboSupplier.SelectedIndex].SupplierNum;
            order.IsNew       = true;
            order.DatePlaced  = new DateTime(2500, 1, 1);
            order.Note        = "";
            SupplyOrders.Insert(order);
            FillGridOrder();
            gridOrder.SetSelected(listOrder.Count - 1, true);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SupplyOrder supplyOrder = db.SupplyOrders.Find(id);

            db.SupplyOrders.Remove(supplyOrder);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 private void OnSetOrder(SupplyOrder order)
 {
     writer.SendUpdate(new FuelSupplyer.Update()
     {
         Order         = order,
         OrderFinished = false,
     });
 }
Example #19
0
 private void RefreshDataGrid()
 {
     if (_selectedSupplier == null)
     {
         return;
     }
     SupplyOrdersDataGrid.ItemsSource = SupplyOrder.GetDueSupplyOrders(_selectedSupplier.Id);
 }
Example #20
0
 private static async void SendToVesselSupplyOrder(SupplyOrder order)
 {
     Logger.Info("SupplyOrder recived");
     lock (thisLock)
     {
         var old = DataAccess.InDataProvider.SupplyOrder.FirstOrDefault(o => o.OrderGuid == order.OrderGuid);
         old.Status = order.Status;
         old.ReceivedAtVesselDate = order.ReceivedAtVesselDate;
         InDataProvider.SaveChanges();
     }
 }
        public ActionResult ApprovalChange(int id = 0)
        {
            SupplyOrder model = new SupplyOrder();
            //model.IsApprovedDate = System.DateTime.Now;
            //model.IsApprovedBy = UserID;
            var repo = new SupplyOrderRepository();

            new SupplyOrderRepository().Approvalcancel(id);
            TempData["success"] = "Approval cancelled successfully";
            return(RedirectToAction("ApprovalCancellation"));
        }
 public ActionResult Edit([Bind(Include = "id,orderid,supplyDate,location,description")] SupplyOrder supplyOrder)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplyOrder).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.orderid = new SelectList(db.order, "id", "description", supplyOrder.orderid);
     return(View(supplyOrder));
 }
Example #23
0
        public void Put(Guid id, [FromBody] SupplyOrder value)
        {
            SupplyOrder supplyOrder = _repository.Find(id);

            if (supplyOrder != null)
            {
                supplyOrder.Copy(value);
                _repository.Update(supplyOrder);
                _repository.SaveAll();
            }
        }
Example #24
0
        ///<summary>Updates one SupplyOrder in the database.</summary>
        internal static void Update(SupplyOrder supplyOrder)
        {
            string command = "UPDATE supplyorder SET "
                             + "SupplierNum   =  " + POut.Long(supplyOrder.SupplierNum) + ", "
                             + "DatePlaced    =  " + POut.Date(supplyOrder.DatePlaced) + ", "
                             + "Note          = '" + POut.String(supplyOrder.Note) + "', "
                             + "AmountTotal   = '" + POut.Double(supplyOrder.AmountTotal) + "' "
                             + "WHERE SupplyOrderNum = " + POut.Long(supplyOrder.SupplyOrderNum);

            Db.NonQ(command);
        }
Example #25
0
        private void gridItems_CellLeave(object sender, ODGridClickEventArgs e)
        {
            int qtyOld = PIn.Int(_tableOrderItems.Rows[e.Row]["Qty"].ToString(), false);
            int qtyNew = 0;

            try {
                qtyNew = PIn.Int(gridItems.ListGridRows[e.Row].Cells[2].Text);              //0 if not valid input
            }
            catch { }
            double priceOld = PIn.Double(_tableOrderItems.Rows[e.Row]["Price"].ToString());
            double priceNew = PIn.Double(gridItems.ListGridRows[e.Row].Cells[3].Text);          //0 if not valid input

            //if(e.Col==2){//Qty
            //gridItems.ListGridRows[e.Row].Cells[2].Text=qtyNew.ToString();//Fix the cell formatting
            //if(qtyOld==qtyNew){
            //don't go to db.
            //gridItems.Invalidate();
            //return;
            //}
            //}
            //if(e.Col==3){//price
            //gridItems.ListGridRows[e.Row].Cells[3].Text=priceNew.ToString("n");//Fix the cell formatting
            //if(priceOld==priceNew){
            //don't go to db.
            //gridItems.Invalidate();
            //return;
            //}
            //}
            //gridItems.ListGridRows[e.Row].Cells[4].Text=(qtyNew*priceNew).ToString("n");
            //gridItems.Invalidate();
            if (qtyOld == qtyNew && priceOld == priceNew)
            {
                FillGridOrderItem(false);                //no refresh
            }
            else
            {
                SupplyOrderItem supplyOrderItem = SupplyOrderItems.SelectOne(PIn.Long(_tableOrderItems.Rows[e.Row]["SupplyOrderItemNum"].ToString()));
                supplyOrderItem.Qty   = qtyNew;
                supplyOrderItem.Price = priceNew;
                SupplyOrderItems.Update(supplyOrderItem);
                SupplyOrder updatedSupplyOrderItem = SupplyOrders.UpdateOrderPrice(supplyOrderItem.SupplyOrderNum);              //this might be an expensive query that we could avoid
                FillGridOrderItem();
                int index = _listSupplyOrders.FindIndex(x => x.SupplyOrderNum == supplyOrderItem.SupplyOrderNum);
                if (index < 0)               //Just in case, shouldn't happen
                {
                    FillGridOrders();
                    return;
                }
                _listSupplyOrders[index] = updatedSupplyOrderItem;
                gridOrders.SelectedGridRows[0].Cells[2].Text = updatedSupplyOrderItem.AmountTotal.ToString("c2");
                gridOrders.Invalidate();
            }
        }
Example #26
0
    /// <summary>
    /// to save the order
    /// </summary>
    /// <author>
    /// Abdullah Al Mohammad
    /// </author>
    /// <updated>
    /// First Updated - 20-07-2007
    /// </updated>
    /// <param name="queryOrders"> query for supply orders</param>
    /// <param name="queryOrdersLine">query for supply ordersline</param>
    private void SaveOrders()
    {
        string exception = "";
        //int value = 0;
        int order_num = mainTable.Rows.Count;

        if (Request.Params["orderNo"] != null)
        {
            ++order_num;
        }


        System.Globalization.CultureInfo        enUS = new System.Globalization.CultureInfo("en-US", true);
        System.Globalization.DateTimeFormatInfo dtfi = new System.Globalization.DateTimeFormatInfo();
        dtfi.ShortDatePattern = "dd-MM-yyyy";
        dtfi.DateSeparator    = "-";

        SupplyOrder objSupplyOrder = new SupplyOrder();

        objSupplyOrder.Dhousenr        = txtDHouse.Text.Replace("<", "").Trim();
        objSupplyOrder.Daddress        = txtDAddress.Text.Replace("<", "").Trim();
        objSupplyOrder.Dpostcode       = txtDPostCode.Text.Replace("<", "").Trim();
        objSupplyOrder.Dresidence      = txtDResidence.Text.Replace("<", "").Trim();
        objSupplyOrder.Dcountry        = ddlDCountry.SelectedValue.ToString();
        objSupplyOrder.Supplyorderid   = Int32.Parse(lblPrintSupplyOrderNo.Text);
        objSupplyOrder.Supplyorderdate = DateTime.Parse(txtOrderDate.Text.Trim(), dtfi);
        objSupplyOrder.Supplierid      = Int32.Parse(ddlSupplier.SelectedValue.ToString());
        objSupplyOrder.Deliverydate    = DateTime.Parse(txtDeliveryDate.Text.Trim(), dtfi);
        objSupplyOrder.Supplyorder_by  = txtOrderBy.Text.Replace("<", "").Trim();
        objSupplyOrder.Receivingstatus = "N";
        objSupplyOrder.Paymentstatus   = "U";


        if (new Facade().SaveSupplyOrder(objSupplyOrder, mainTable, (object)Request.Params["orderNo"], order_num, ref msg))
        {
            if (!msg.Equals("sent"))
            {
                msg = "saved";
            }

            lblMessage.Text = "You have successfully " + msg + " order # " + lblPrintSupplyOrderNo.Text + ".";
            msg             = "";
            //lnkSubmit.Visible = false;
            //lnkSendOrder.Visible = false;
            //grdOrder.DeleteRow(grdOrder.Rows.Count);
            //grdOrder.DataSource = null;
            //grdOrder.DataBind();
        }
        else
        {
            lblMessage.Text = exception;
        }
    }
Example #27
0
        public void Approve(Guid id)
        {
            SupplyOrder order = _repository.Find(id);

            if (order != null)
            {
                order.Authorization = true;
                _repository.Update(order);
                _repository.SaveAll();
                MakePurchaseService.SendProductsToStock(order);
            }
        }
Example #28
0
 public SupplyOrderConfirmationWindow(SupplyOrder newOrder, Supplier supplier, SupplyOrderWindow window)
 {
     InitializeComponent();
     OrderEntriesListBox.ItemsSource = newOrder.OrderEntries;
     IdLabel.Content           = "SupplyOrder: " + newOrder.Id;
     SupplierNameLabel.Content = supplier.Name;
     ContactLabel.Content      = supplier.ContactInfo;
     TotalLabel.Content        = newOrder.Total;
     Cash_CreditLabel.Content  = newOrder.Paid ? "Cash" : "Credit";
     _observer = window;
     VerifyButton.Focus();
 }
Example #29
0
        public void AddSupplyOrder()
        {
            int tempId = SupplyOrder.GetNextOrderId();
            SupplyOrderEntry tempEntry1 = new SupplyOrderEntry(tempId, 1, "tempName1", 1, 1000);
            SupplyOrderEntry tempEntry2 = new SupplyOrderEntry(tempId, 2, "tempName2", 1, 1000);
            SupplyOrder      newOrder   = new SupplyOrder(tempId, 1);

            newOrder.AddEntry(tempEntry1);
            newOrder.AddEntry(tempEntry2);
            newOrder.SupplierId   = 1;
            newOrder.SupplierName = "Randil";
            Assert.IsTrue(SupplyOrder.AddSupplyOrder(newOrder));
        }
Example #30
0
        public static void SendProductsToStock(SupplyOrder supplyOrder)
        {
            //Simula envio (via integração?) para outro módulo ou sistema
            IList <ProductQuotation> ProductQuotations = supplyOrder.SelectedPrice.ProductQuotations.ToList();

            foreach (ProductQuotation p in ProductQuotations)
            {
                //aqui temos acesso ao produto, fonecedor, comprador, preço, quantidade e afins
                //nosso sistema foi retirado de um conjunto de estoque, então não implementamos a integtação final enviando os produtos
                //mas deixamos o código para mostrar que todas as informações necessárias para realizar a entrega
                //estão disponiveis através deste metodo
            }
        }
Example #31
0
        ///<summary>Updates one SupplyOrder in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(SupplyOrder supplyOrder, SupplyOrder oldSupplyOrder)
        {
            string command = "";

            if (supplyOrder.SupplierNum != oldSupplyOrder.SupplierNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SupplierNum = " + POut.Long(supplyOrder.SupplierNum) + "";
            }
            if (supplyOrder.DatePlaced.Date != oldSupplyOrder.DatePlaced.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DatePlaced = " + POut.Date(supplyOrder.DatePlaced) + "";
            }
            if (supplyOrder.Note != oldSupplyOrder.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = " + DbHelper.ParamChar + "paramNote";
            }
            if (supplyOrder.AmountTotal != oldSupplyOrder.AmountTotal)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AmountTotal = '" + POut.Double(supplyOrder.AmountTotal) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            if (supplyOrder.Note == null)
            {
                supplyOrder.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(supplyOrder.Note));

            command = "UPDATE supplyorder SET " + command
                      + " WHERE SupplyOrderNum = " + POut.Long(supplyOrder.SupplyOrderNum);
            Db.NonQ(command, paramNote);
            return(true);
        }
Example #32
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<SupplyOrder> TableToList(DataTable table){
			List<SupplyOrder> retVal=new List<SupplyOrder>();
			SupplyOrder supplyOrder;
			for(int i=0;i<table.Rows.Count;i++) {
				supplyOrder=new SupplyOrder();
				supplyOrder.SupplyOrderNum= PIn.Long  (table.Rows[i]["SupplyOrderNum"].ToString());
				supplyOrder.SupplierNum   = PIn.Long  (table.Rows[i]["SupplierNum"].ToString());
				supplyOrder.DatePlaced    = PIn.Date  (table.Rows[i]["DatePlaced"].ToString());
				supplyOrder.Note          = PIn.String(table.Rows[i]["Note"].ToString());
				supplyOrder.AmountTotal   = PIn.Double(table.Rows[i]["AmountTotal"].ToString());
				retVal.Add(supplyOrder);
			}
			return retVal;
		}
Example #33
0
    private void _Update()
    {
        if (worker && worker.WorkTime() && worker.fsm.ActiveStateName == "Idle")
        {        //Resupply Items for sale
            if (!supply)
            {
                supplyOrder = orders.Find(o => storage.Count(o.type) < o.min);
                if (supplyOrder != null)
                {
                    supply = true;
                }
            }
            else
            {
                if (storage.Count(supplyOrder.type) >= supplyOrder.max)
                {
                    supply = false;
                }
            }

            if (supply)
            {
                int missingCount = supplyOrder.max - storage.Count(supplyOrder.type);

                Item    item          = null;
                Storage sourceStorage = null;

                if (supplyStorage && SearchFor.ItemInStorage(supplyOrder.type, supplyStorage, out item))
                {
                    sourceStorage = supplyStorage;
                }
                if (!item)
                {
                    SearchFor.ItemInStorageStructures(supplyOrder.type, transform.position, out item, out sourceStorage);
                }
                if (!item)
                {
                    SearchFor.ItemInCraftStructures(supplyOrder.type, transform.position, out item);
                }
                //if (!item)
                //SearchFor.ItemInShopStructures(supplyOrder.type, transform.position, out item, out sourceStorage);

                //Store Item
                if (item)
                {
                    worker.fsm.Store(item, sourceStorage, storage);
                }
            }
        }
    }
Example #34
0
		///<summary>Updates one SupplyOrder in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(SupplyOrder supplyOrder,SupplyOrder oldSupplyOrder){
			string command="";
			if(supplyOrder.SupplierNum != oldSupplyOrder.SupplierNum) {
				if(command!=""){ command+=",";}
				command+="SupplierNum = "+POut.Long(supplyOrder.SupplierNum)+"";
			}
			if(supplyOrder.DatePlaced != oldSupplyOrder.DatePlaced) {
				if(command!=""){ command+=",";}
				command+="DatePlaced = "+POut.Date(supplyOrder.DatePlaced)+"";
			}
			if(supplyOrder.Note != oldSupplyOrder.Note) {
				if(command!=""){ command+=",";}
				command+="Note = '"+POut.String(supplyOrder.Note)+"'";
			}
			if(supplyOrder.AmountTotal != oldSupplyOrder.AmountTotal) {
				if(command!=""){ command+=",";}
				command+="AmountTotal = '"+POut.Double(supplyOrder.AmountTotal)+"'";
			}
			if(command==""){
				return false;
			}
			command="UPDATE supplyorder SET "+command
				+" WHERE SupplyOrderNum = "+POut.Long(supplyOrder.SupplyOrderNum);
			Db.NonQ(command);
			return true;
		}
Example #35
0
		///<summary>Updates one SupplyOrder in the database.</summary>
		public static void Update(SupplyOrder supplyOrder){
			string command="UPDATE supplyorder SET "
				+"SupplierNum   =  "+POut.Long  (supplyOrder.SupplierNum)+", "
				+"DatePlaced    =  "+POut.Date  (supplyOrder.DatePlaced)+", "
				+"Note          = '"+POut.String(supplyOrder.Note)+"', "
				+"AmountTotal   = '"+POut.Double(supplyOrder.AmountTotal)+"' "
				+"WHERE SupplyOrderNum = "+POut.Long(supplyOrder.SupplyOrderNum);
			Db.NonQ(command);
		}