Example #1
0
        public enumStatus AddOrder(Order order)
        {
            string jsonDoc = order.ToString();

            try
            {
                Orders.Add(order.Id, jsonDoc);
                if (!OrderTable.ContainsKey(order.UserID))
                {
                    List <Order> orders = new List <Order>();
                    OrderTable[order.UserID] = orders;
                }
                OrderTable[order.UserID].Add(order);
                return(enumStatus.OrderPlaced);
            }
            catch (Exception ex)
            {
                ServerLog.LogException(ex, string.Format("Add Order: {0}", order.ToString()));
                return(enumStatus.OrderPlaceError);
            }
            //lock (syncRoot)
            //{

            //}
        }
Example #2
0
 public frmShowBill(Customer customer, OrderTable order)
 {
     InitializeComponent();
     db  = new BidaDataContext();
     ord = order;
     cus = customer;
 }
 public Order_Detail(OrderTable orderTable)
 {
     InitializeComponent();
     init();
     DataContext = orderTable;
     newOrder    = orderTable;
 }
        private void add()
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            OrderTable dt = new OrderTable();

            try
            {
                // domainUpDown1
                dt.DrugID        = Int32.Parse(domainUpDown2.Text);
                dt.DrugName      = textBox3.Text;
                dt.QuantityToAdd = Int32.Parse(textBox4.Text);
                dt.AdminID       = adminID;
                dt.OrderDate     = DateTime.Now;
                //dt.OrderReceiveDate = DateTime.Parse(dateTimePicker2.Text);
                dt.VendorID    = Int32.Parse(domainUpDown3.Text);
                dt.OrderStatus = "Ordered";

                db.OrderTables.InsertOnSubmit(dt);
                db.SubmitChanges();

                MessageBox.Show("Succesfully added!\nPlease check in order to receive the order!");
                clearFields();
                loadDomainBoxOrderID();
            }

            catch
            {
                MessageBox.Show("invalid input");
            }
        }
 /// <summary>
 /// update booktitle based in id
 /// </summary>
 /// <param name="booktitle"></param>
 public static void UpdateOrder(OrderTable order)
 {
     db4oManager.WithContainer(container =>
     {
         // The office object that is passed to this procedure is not connected to
         // the db4o container so we first have to do that.
         List <OrderTable> _list = (from OrderTable o in container
                                    where o.OrderID == order.OrderID && o.OrderNumber == order.OrderNumber
                                    select o).ToList();
         if (_list != null)
         {
             // Then we should pass the properties from the updated object to the
             // selected one.
             // TODO: Maybe we could make a reflection procedure for this?
             //defaults
             _list[0].OrderNumber      = order.OrderNumber;
             _list[0].OfficeIndicator  = order.OfficeIndicator;
             _list[0].DateOrderCreated = order.DateOrderCreated;
             _list[0].EWDLastUpdated   = order.EWDLastUpdated; //exworks last updated
             //dlls
             _list[0].OrderControllerID      = order.OrderControllerID;
             _list[0].OperationsControllerID = order.OperationsControllerID;
             _list[0].CompanyID              = order.CompanyID;
             _list[0].CountryID              = order.CountryID;
             _list[0].OriginPointID          = order.OriginPointID;
             _list[0].PortID                 = order.PortID;
             _list[0].DestinationPortID      = order.DestinationPortID;
             _list[0].FinalDestinationID     = order.FinalDestinationID;
             _list[0].ContactID              = order.ContactID;
             _list[0].PrinterID              = order.PrinterID;
             _list[0].AgentAtOriginID        = order.AgentAtOriginID;
             _list[0].OriginPortControllerID = order.OriginPortControllerID;
             //dates
             _list[0].ExWorksDate      = order.ExWorksDate;
             _list[0].CargoReady       = order.CargoReady;
             _list[0].WarehouseDate    = order.WarehouseDate;
             _list[0].BookingReceived  = order.BookingReceived;
             _list[0].DocsApprovedDate = order.DocsApprovedDate;
             //checkboxes
             _list[0].PublishipOrder     = order.PublishipOrder;
             _list[0].HotJob             = order.HotJob;
             _list[0].Palletise          = order.Palletise;
             _list[0].DocsRcdAndApproved = order.DocsRcdAndApproved;
             _list[0].ExpressBL          = order.ExpressBL;
             _list[0].FumigationCert     = order.FumigationCert;
             _list[0].GSPCert            = order.GSPCert;
             _list[0].PackingDeclaration = order.PackingDeclaration;
             //memos
             _list[0].RemarksToCustomer = order.RemarksToCustomer;
             _list[0].Remarks           = order.Remarks;
             _list[0].OtherDocsRequired = order.OtherDocsRequired;
             //text boxes
             _list[0].CustomersRef     = order.CustomersRef;
             _list[0].Sellingrate      = order.Sellingrate;
             _list[0].SellingrateAgent = order.SellingrateAgent;
             //save
             container.Store(_list[0]);
         }
     });
 }
        private void cancel()
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            OrderTable dt = new OrderTable();

            try
            {
                var q = from OrderTable in db.OrderTables
                        where OrderTable.Id == Int32.Parse(domainUpDown1.Text)
                        select OrderTable;

                db.OrderTables.DeleteAllOnSubmit(q);
                db.SubmitChanges();
                MessageBox.Show("Succesfully cancelled!\n");


                DrugTable q2 = (from DrugTable in db.DrugTables
                                where DrugTable.Id == Int32.Parse(domainUpDown2.Text)
                                select DrugTable).Single();
                q2.Status = "valid";
                db.SubmitChanges();

                clearFields();
                loadDomainBoxOrderID();
            }
            catch
            {
                MessageBox.Show("invalid input\n");
            }
        }
        private void update()
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            OrderTable dt = new OrderTable();

            try
            {
                OrderTable q = (from OrderTable in db.OrderTables
                                where OrderTable.Id == Int32.Parse(domainUpDown1.Text)
                                select OrderTable).Single();
                q.DrugID        = Int32.Parse(domainUpDown2.Text);
                q.DrugName      = textBox3.Text;
                q.QuantityToAdd = Int32.Parse(textBox4.Text);
                //dt.OrderReceiveDate = DateTime.Parse(dateTimePicker2.Text);
                q.VendorID = Int32.Parse(domainUpDown3.Text);

                db.SubmitChanges();
                MessageBox.Show("Succesfully updated!\nPlease check in order to receive the order!");
                clearFields();
                loadDomainBoxOrderID();
            }
            catch
            {
                MessageBox.Show("invalid input\n");
            }
        }
Example #8
0
    public List <OrderTable> dsOrderTable()
    {
        List <OrderTable> listOrderTable  = new List <OrderTable>();
        string            sqlslOrderTable = "select * from OrderTable";

        con.Open();
        SqlCommand    cmd = new SqlCommand(sqlslOrderTable, con);
        SqlDataReader dr  = cmd.ExecuteReader();

        while (dr.Read())
        {
            OrderTable tb = new OrderTable();
            tb.ordertable_id      = (int)dr["ordertable_id"];
            tb.ordertable_iduser  = (int)dr["ordertable_iduser"];
            tb.ordertable_timeset = (DateTime)dr["ordertable_timeset"];
            tb.ordertable_idtable = (int)dr["ordertable_idtable"];
            tb.ordertable_status  = (bool)dr["ordertable_status"];



            listOrderTable.Add(tb);
        }
        con.Close();
        return(listOrderTable);
    }
Example #9
0
        public IHttpActionResult PostCustomerTable(string id)
        {
            OrderTable       Order = new OrderTable();
            CartOrderDetails cart  = new CartOrderDetails();

            cart.ListOfProductsInCart = new List <OrderProductLineForCart>();

            List <CartTable> CartRows = db.CartTables.Where(c => c.CustomerID == id).ToList();

            foreach (CartTable CartItem in CartRows)
            {
                cart.ListOfProductsInCart.Add(new OrderProductLineForCart
                {
                    Quantity     = CartItem.Quantity,
                    DiscountRate = (int)CartItem.ProductTable.Discount,
                    Rate         = (int)CartItem.ProductTable.Prize
                });

                db.CartTables.Remove(CartItem);
            }
            Order.NetAmount  = cart.TotalCartAmount;
            Order.CustomerID = id;
            Order.OrderDate  = DateTime.Now;

            return(Ok());
        }
        public IHttpActionResult PostOrderTable(OrderTable orderTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.OrderTables.Add(orderTable);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (OrderTableExists(orderTable.OrderDate))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = orderTable.OrderDate }, orderTable));
        }
Example #11
0
        public ActionResult PlaceOrder(OrderTable model)
        {
            var datastock = dbObj.Product_table.Where(m => m.ID == model.Product_table.ID).FirstOrDefault().Items_In_Stock;

            if (datastock <= 1)
            {
                ModelState.AddModelError("ProductID", "Product is out of stock");
            }
            if (ModelState.IsValid)
            {
                OrderTable obj = new OrderTable();
                //var prodId = dbObj.Product_table.Where(m => m.Product_Name == model.Product_table.Product_Name).FirstOrDefault().ID;
                obj.ProductID     = model.Product_table.ID;
                obj.UserID        = model.UserTable.ID;
                obj.Status        = "ordered";
                obj.Product_table = dbObj.Product_table.Where(m => m.ID == model.Product_table.ID).FirstOrDefault();
                obj.UserTable     = dbObj.UserTables.Where(m => m.ID == model.UserTable.ID).FirstOrDefault();
                obj.Product_table.Items_In_Stock -= 1;

                if (model.ID == 0)
                {
                    dbObj.OrderTables.Add(obj);
                }
                else
                {
                    dbObj.Entry(obj).State = EntityState.Modified;
                }
                dbObj.SaveChanges();
                ViewData["NumbeOfItemsInStock"] = obj.Product_table.Items_In_Stock;
                ModelState.Clear();
            }
            //ModelState.Clear();
            return(View("ProductOrder"));
        }
Example #12
0
        public async Task <IActionResult> Edit(int id, [Bind("TableId,TableNumber")] OrderTable orderTable)
        {
            if (id != orderTable.TableId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderTable);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderTableExists(orderTable.TableId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(orderTable));
        }
    protected void updatotb_Click(object sender, EventArgs e)
    {
        try
        {
            Boolean tttt;
            if (rdodtt.Checked == true)
            {
                tttt = true;
            }
            else
            {
                tttt = false;
            }

            var otb = new OrderTable()
            {
                ordertable_iduser  = Convert.ToInt16(txtuser.Text),
                ordertable_timeset = Convert.ToDateTime(dt.Value.ToString()),
                ordertable_idtable = Convert.ToInt16(txtidb.Text),
                ordertable_id      = Convert.ToInt16(Session["idotb"].ToString()),
                ordertable_status  = tttt
            };
            data.suaotb(otb);
            mss.Text      = "Update success!";
            mss.ForeColor = System.Drawing.Color.Green;
            ShowInfooTable();
        }
        catch (Exception ex)
        {
            mss.Text      = "Update Fail. Erorr: " + ex.Message + ". Let try!";
            mss.ForeColor = System.Drawing.Color.Red;
        }
    }
Example #14
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderId,ShaoppingName,MoneyType,MoneyState,UserName,OrderPhone,OrderAddress,OrderState,DistributionDealer,Engine,CarColor,OrderTime,MoneyTime,MoneyBank,PayType,PayMoney,LatelyTime,OrderTransfer")] OrderTable orderTable)
        {
            if (id != orderTable.OrderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderTable);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderTableExists(orderTable.OrderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(orderTable));
        }
Example #15
0
        public Order CreateOrder(string u)
        {
            Order order = null;

            try
            {
                OrderTable o = _unitOfWork.Orders.CreateOrder(u);
                List <JobPortal.Model.Saleline> salelines = new List <JobPortal.Model.Saleline>();
                foreach (var item in o.Salelines)
                {
                    salelines.Add(new JobPortal.Model.Saleline {
                        Id = item.ID, ServiceOfferId = item.ServiceOffer_ID
                    });
                }
                order = new Order {
                    ID = o.ID, TotalPrice = o.TotalPrice, OrderStatus = o.OrderStatus.Order_status, User_ID = o.Users_ID, Salelines = salelines
                };
            }
            catch (BookedTimeException e)
            {
                throw new FaultException <BookedTimeException>
                          (e, new FaultReason(e.GetMessage()), new FaultCode("Sender"));
            }
            return(order);
        }
        // GET: OrderTables
        public IActionResult Index(OrderTable ot)
        {
            string email = User.Identity.Name;

            var customers = _context.Customers
                            .Where(c => c.Email == email)
                            .Select(id => id.CustomerId)
                            .ToList();

            int customerId = customers.First();

            var lines = _context.ChartLines
                        .Where(c => c.ChartId == customerId);

            foreach (var i in lines)
            {
                _context.ChartLines.Remove(i);
            }
            _context.Charts.Find(customerId).Cost = 0;
            _context.SaveChangesAsync();



            return(View(ot));
        }
Example #17
0
        /// <summary>
        ///  OrderTable
        /// </summary>
        /// <param name="OrderTable">OrderTable实体对象</param>
        public void Insert(OrderTable obj)
        {
            try
            {
                string sql = "insert into Orders(UID,PlatformID,OrderTxid, Type1,LimitType,Status,Pair,Coin,Currency,Volume,LimitPrice,Price,Opened,Closed,CreateTime,LastChangeTime) " +
                             " values(@UID,@PlatformID,@OrderTxid, @Type,@LimitType,@Status,@Pair,@Coin,@Currency,@Volume,@LimitPrice,@Price,@Opened,@Closed,datetime('now', 'localtime'),datetime('now', 'localtime'))";

                using (SQLiteCommand cmd = new SQLiteCommand(sql))
                {
                    cmd.Parameters.AddWithValue("@UID", obj.UID);
                    cmd.Parameters.AddWithValue("@PlatformID", obj.Platform.ID);
                    cmd.Parameters.AddWithValue("@OrderTxid", obj.OrderTxid);
                    cmd.Parameters.AddWithValue("@Type", obj.Type);
                    cmd.Parameters.AddWithValue("@LimitType", obj.LimitType);
                    cmd.Parameters.AddWithValue("@Status", obj.Status);
                    cmd.Parameters.AddWithValue("@Pair", obj.Pair);
                    cmd.Parameters.AddWithValue("@Coin", obj.Coin);
                    cmd.Parameters.AddWithValue("@Currency", obj.Currency);
                    cmd.Parameters.AddWithValue("@Volume", obj.Volume);
                    cmd.Parameters.AddWithValue("@LimitPrice", obj.LimitPrice);
                    cmd.Parameters.AddWithValue("@Price", obj.Price);
                    cmd.Parameters.AddWithValue("@Opened", obj.Opened);
                    cmd.Parameters.AddWithValue("@Closed", obj.Closed);

                    SQLiteHelper.SQLiteHelper.ExecuteNonQuery(conStr, cmd);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("调用OrderTable时,访问Insert时出错", ex);
            }
        }
Example #18
0
        public int filledUpdateDb(double fillPrice, LiveSystem liveSystem, string topicPrefix)
        {
            int liveOrderId;

            if (ferretSubmission == null)
            {
                liveOrderId = LiveOrders.ORDERS.insert(
                    liveSystem.id(), symbol.name, jDate(now()), null, enterExit(),
                    positionDirection().ToString(), size, new java.lang.Double(fillPrice),
                    details.ToString(), description, hostname(), topicPrefix, null
                    );
            }
            else
            {
                liveOrderId = ferretSubmission.liveOrderId;
                var submitted = LiveOrders.ORDERS.order(liveOrderId);
                submitted.updateFill(fillPrice, jDate(now()));
            }
            Db.commit();
            OrderTable.topic().send(new Dictionary <string, object> {
                { "liveOrderId", liveOrderId },
                { "timestamp", ymdHuman(now()) }
            });
            return(liveOrderId);
        }
        public async Task <IActionResult> Edit(int id, [Bind("TotalPrice,OrderId,CustomerId,OrderDate")] OrderTable orderTable)
        {
            if (id != orderTable.OrderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderTable);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderTableExists(orderTable.OrderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "Address", orderTable.CustomerId);
            return(View(orderTable));
        }
Example #20
0
        public ActionResult <OrderTableViewModel> Edit(OrderTable orderTable)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }

                var entity = _ordertableservice.GetContext().OrderTable.Find(orderTable.Id);
                if (entity == null)
                {
                    return(NoContent());
                }

                _ordertableservice.GetContext().Entry(entity).CurrentValues.SetValues(orderTable);
                _ordertableservice.GetContext().SaveChanges();
                var x = _ordertableservice.GetById(orderTable.Id);


                return(Ok(x));
            }
            catch (ArgumentNullException)
            {
                return(NoContent());
            }
        }
        public IHttpActionResult PutOrderTable(string id, OrderTable orderTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != orderTable.OrderDate)
            {
                return(BadRequest());
            }

            db.Entry(orderTable).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderTableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #22
0
        /// <summary>
        /// 修改OrderTable
        /// </summary>
        /// <param name="OrderTable">OrderTable实体对象</param>
        /// <returns>状态代码</returns>
        public int Update(OrderTable obj)
        {
            try
            {
                string sql = "UPDATE Orders set UID=@UID,PlatformID=@PlatformID,OrderTxid=@OrderTxid, Type1=@Type1, LimitType=@LimitType,Status=@Status,Pair=@Pair,Coin=@Coin,Currency=@Currency," +
                             " Volume=@Volume,LimitPrice=@LimitPrice,Price=@Price,Opened=@Opened,Closed=@Closed,LastChangeTime=datetime('now', 'localtime') where id=@ID";

                using (SQLiteCommand cmd = new SQLiteCommand(sql))
                {
                    cmd.Parameters.AddWithValue("@ID", obj.ID);
                    cmd.Parameters.AddWithValue("@UID", obj.UID);
                    cmd.Parameters.AddWithValue("@PlatformID", obj.Platform.ID);
                    cmd.Parameters.AddWithValue("@OrderTxid", obj.OrderTxid);
                    cmd.Parameters.AddWithValue("@Type1", obj.Type);
                    cmd.Parameters.AddWithValue("@LimitType", obj.LimitType);
                    cmd.Parameters.AddWithValue("@Status", obj.Status);
                    cmd.Parameters.AddWithValue("@Pair", obj.Pair);
                    cmd.Parameters.AddWithValue("@Coin", obj.Coin);
                    cmd.Parameters.AddWithValue("@Currency", obj.Currency);
                    cmd.Parameters.AddWithValue("@Volume", obj.Volume);
                    cmd.Parameters.AddWithValue("@LimitPrice", obj.LimitPrice);
                    cmd.Parameters.AddWithValue("@Price", obj.Price);
                    cmd.Parameters.AddWithValue("@Opened", obj.Opened);
                    cmd.Parameters.AddWithValue("@Closed", obj.Closed);

                    return(SQLiteHelper.SQLiteHelper.ExecuteNonQuery(conStr, cmd));
                }
            }
            catch (Exception ex)
            {
                throw new Exception("调用OrderTable 时,访问Update时出错", ex);
            }
        }
        public void Luu_HD(ListView.ListViewItemCollection list_cthd, string mahd, string ncc, DateTimePicker ngay_dat_hang)
        {
            OrderTable hd = new OrderTable();


            hd.orderID = Convert.ToInt32(mahd);
            // hd.userID = 1;
            hd.userID    = data.NVs.First(x => x.userAccount == frm_Login.LoginAccount).userID;
            hd.status    = 1;
            hd.orderDate = Convert.ToDateTime(ngay_dat_hang.Value.ToShortDateString());
            hd.VendorID  = data.Vendors.First(x => x.VendorName == ncc).VendorID;
            data.OrderTables.InsertOnSubmit(hd);
            data.SubmitChanges();
            foreach (ListViewItem lvi in list_cthd)
            {
                if (lvi.Text != "Thêm sản phẩm")
                {
                    OrderDetail cthd = new OrderDetail();
                    cthd.orderDetailID = Convert.ToInt32(lvi.SubItems[0].Text);
                    cthd.orderID       = hd.orderID;
                    cthd.ProductID     = data.Products.First(x => x.ProductName == lvi.SubItems[1].Text).ProductID;
                    cthd.tax           = Convert.ToDouble(lvi.SubItems[4].Text);
                    cthd.UnitPrice     = Convert.ToInt32(lvi.SubItems[3].Text);
                    cthd.orderQuantity = Convert.ToInt32(lvi.SubItems[2].Text);
                    data.OrderDetails.InsertOnSubmit(cthd);
                    data.SubmitChanges();
                }
            }
        }
Example #24
0
        public enumStatus UpdateOrder(Order order)
        {
            string jsonDoc = order.ToString();

            try
            {
                lock (syncRoot)
                {
                    if (!Orders.ContainsKey(order.Id))
                    {
                        ServerLog.LogError("Update Order, invalid Order Id: {0}", order.Id);
                        return(enumStatus.Error);
                    }
                    if (!Users.ContainsKey(order.UserID) || !OrderTable.ContainsKey(order.UserID))
                    {
                        ServerLog.LogError("Update Order, invalid User Id {0} in the order: {1}", order.UserID, order);
                        return(enumStatus.Error);
                    }
                    int i = OrderTable[order.UserID].Select(a => a.Id).ToList().IndexOf(order.Id);
                    if (i >= 0)
                    {
                        OrderTable[order.UserID][i] = order;
                    }
                    Orders[order.Id] = jsonDoc;
                }
                return(enumStatus.Successful);
            }
            catch (Exception ex)
            {
                ServerLog.LogException(ex, string.Format("Update Order: {0}", order.ToString()));
                return(enumStatus.Error);
            }
        }
Example #25
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderIdPk,UsernameFk,OrderTotalCost,OrderDateTime,LocationFk")] OrderTable orderTable)
        {
            if (id != orderTable.OrderIdPk)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderTable);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderTableExists(orderTable.OrderIdPk))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LocationFk"] = new SelectList(_context.LocationTable, "LocationPk", "LocationPk", orderTable.LocationFk);
            ViewData["UsernameFk"] = new SelectList(_context.UserTable, "UsernamePk", "UsernamePk", orderTable.UsernameFk);
            return(View(orderTable));
        }
 /// <summary>
 /// update booktitle based in id
 /// </summary>
 /// <param name="booktitle"></param>
 public static void UpdateOrder(OrderTable order)
 {
     db4oManager.WithContainer(container =>
     {
         // The office object that is passed to this procedure is not connected to
         // the db4o container so we first have to do that.
         List<OrderTable> _list = (from OrderTable o in container
                                  where o.OrderID == order.OrderID  && o.OrderNumber == order.OrderNumber
                                  select o).ToList();
         if (_list != null)
         {
             // Then we should pass the properties from the updated object to the 
             // selected one. 
             // TODO: Maybe we could make a reflection procedure for this?
             //defaults
             _list[0].OrderNumber = order.OrderNumber;
             _list[0].OfficeIndicator = order.OfficeIndicator;
             _list[0].DateOrderCreated = order.DateOrderCreated;
             _list[0].EWDLastUpdated = order.EWDLastUpdated; //exworks last updated
             //dlls
             _list[0].OrderControllerID = order.OrderControllerID;
             _list[0].OperationsControllerID = order.OperationsControllerID;
             _list[0].CompanyID = order.CompanyID;
             _list[0].CountryID = order.CountryID;
             _list[0].OriginPointID = order.OriginPointID;
             _list[0].PortID = order.PortID;
             _list[0].DestinationPortID = order.DestinationPortID;
             _list[0].FinalDestinationID = order.FinalDestinationID;
             _list[0].ContactID = order.ContactID;
             _list[0].PrinterID = order.PrinterID;
             _list[0].AgentAtOriginID = order.AgentAtOriginID;
             _list[0].OriginPortControllerID = order.OriginPortControllerID;
             //dates
             _list[0].ExWorksDate = order.ExWorksDate;
             _list[0].CargoReady = order.CargoReady;
             _list[0].WarehouseDate = order.WarehouseDate;
             _list[0].BookingReceived = order.BookingReceived;
             _list[0].DocsApprovedDate = order.DocsApprovedDate;
             //checkboxes  
             _list[0].PublishipOrder = order.PublishipOrder;
             _list[0].HotJob = order.HotJob;
             _list[0].Palletise = order.Palletise;
             _list[0].DocsRcdAndApproved = order.DocsRcdAndApproved;
             _list[0].ExpressBL = order.ExpressBL;
             _list[0].FumigationCert = order.FumigationCert;
             _list[0].GSPCert = order.GSPCert;
             _list[0].PackingDeclaration = order.PackingDeclaration;
             //memos
             _list[0].RemarksToCustomer = order.RemarksToCustomer;
             _list[0].Remarks = order.Remarks;
             _list[0].OtherDocsRequired = order.OtherDocsRequired;
             //text boxes
             _list[0].CustomersRef = order.CustomersRef;
             _list[0].Sellingrate = order.Sellingrate;
             _list[0].SellingrateAgent = order.SellingrateAgent;
             //save               
             container.Store(_list[0]);
         }
     });
 }
        /// <summary>
        /// 立即购买
        /// </summary>
        /// <param name="GoodsId">商品id</param>
        /// <param name="ShoppingNum">购买数量</param>
        /// <param name="OrderAmount">小计</param>
        /// <returns></returns>
        public JsonResult AddOrder(string GoodsId, string ShoppingNum, string OrderAmount)
        {
            UserInfo user = Session["user"] as UserInfo;

            //判断收货地址是否为空
            if (user.ReceivingAddress == "")
            {
                return(Json(3, JsonRequestBehavior.AllowGet));
            }
            //余额是否满足
            if (user.UserWallet < Convert.ToDecimal(OrderAmount))
            {
                return(Json(2, JsonRequestBehavior.AllowGet));
            }
            OrderTable ord = new OrderTable()
            {
                GoodsID     = Convert.ToInt32(GoodsId),
                UserID      = Convert.ToInt32(Session["userid"]),
                GoodsNum    = Convert.ToInt32(ShoppingNum),
                GetTime     = DateTime.Now,
                OrderAmount = Convert.ToDecimal(OrderAmount),
                IsComment   = 0,
                IsReceiving = 0
            };

            if (OrderBll.AddOrder(ord))
            {
                return(Json(1, JsonRequestBehavior.AllowGet));
            }
            return(Json(0, JsonRequestBehavior.AllowGet));
        }
        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            if (txtName.Text == string.Empty || txtBAdress.Text == string.Empty || txtCreditNum.Text == string.Empty ||
                txtCreditExpir.Text == string.Empty || txtCVC.Text == string.Empty || txtShippingAdr.Text == string.Empty)
            {
                Toast.MakeText(this, "Missing Required Field", ToastLength.Short).Show();
                return;
            }

            try
            {
                string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3");
                var    db     = new SQLiteConnection(dpPath);
                db.CreateTable <OrderTable>();
                OrderTable tbl = new OrderTable();
                tbl.name            = txtName.Text;
                tbl.billingAddress  = txtBAdress.Text;
                tbl.creditCardNum   = txtCreditNum.Text;
                tbl.expirDate       = txtCreditExpir.Text;
                tbl.cvc             = txtCVC.Text;
                tbl.shippingAddress = txtShippingAdr.Text;
                db.Insert(tbl);
                Toast.MakeText(this, "Order Submitted Successfully!", ToastLength.Short).Show();
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.ToString(), ToastLength.Short).Show();
            }

            StartActivity(typeof(LoginActivity));
        }
Example #29
0
        public void act()
        {
            List <Cook>          cookList           = KitchenActorList.Instance.cookList;
            List <KitchenClerck> kitchenClercksList = KitchenActorList.Instance.kitchenClerkList;
            Cook          theCook          = null;
            KitchenClerck theKitchenClerck = null;
            Boolean       CKMustCook       = false;

            //Selection des acteurs
            foreach (Cook cook in cookList)
            {
                if (cook.lockAction.Equals(false))
                {
                    theCook = cook;
                }                                                      //On choisis un cook disponible
            }
            foreach (KitchenClerck kc in kitchenClercksList)
            {
                if (kc.lockAction.Equals(false))
                {
                    theKitchenClerck = kc;
                }                                                           //On choisis un KC disponible
            }

            if ((theCook != null) && (theKitchenClerck != null)) //Si deux acteurs sont disponible
            {
                OrderTable orderTable = InitKitchen.Instance.orderTable;

                foreach (Order order in orderTable.orderList)
                { //On consulte tous les order qui sont à faire
                    foreach (Menu menu in order.orderList)
                    {
                        foreach (Dish dish in menu.dishList)
                        {
                            foreach (Instruction instruction in dish.instructionsList)
                            {
                                if (instruction.kitchenAction.name.Equals("Chop Vegetables"))
                                {
                                    CKMustCook = true;
                                }
                            }
                            if (CKMustCook)                                //Si nécessité de chop vegetables
                            {
                                theKitchenClerck.action("ChopVegetables"); //Demander au comis de préparer le plat
                                return;
                            }
                            else //Cook cuisine directement
                            {
                                theCook.action("PrepareDish");
                                return;
                            }
                        }
                    }
                }
            }
            else
            {
                //Reesayer plus tard
            }
        }
        public void huy_HD(int id, string a)
        {
            OrderTable hd_sp = data.OrderTables.First(x => x.orderID == id);

            hd_sp.status = a == "Đang yêu cầu" ? 2 : 1;
            data.SubmitChanges();
        }
        public void thay_doi_tinh_trang_HD(int id, string a)
        {
            OrderTable hd_sp = data.OrderTables.First(x => x.orderID == id);

            hd_sp.status = a == "Đang yêu cầu" ? 0 : 1;
            data.SubmitChanges();
        }
        //end select title
        /// <summary>
        /// returns orderid if save is successful
        /// </summary>
        /// <param name="booktitle"></param>
        /// <returns></returns>
        public static int InsertOrder(OrderTable order)
        {
            db4oManager.WithContainer(container =>
            {
                container.Store(order);
            });

            return order.OrderID;
        }
Example #33
0
 protected void GridViewCustomers_SelectedIndexChanged(object sender, EventArgs e)
 {
     int Empl_id = Int32.Parse(DropDownList1.SelectedValue.ToString());
     int Cust_id = Int32.Parse(GridViewCustomers.SelectedValue.ToString());
     string EAN = Server.UrlDecode(Request.QueryString["EAN"]);
     int count = Int32.Parse(TextBoxCount.Text);
     OkPneuTire tire = new OkPneuTire();
     OkPneuTireTable okTable = new OkPneuTireTable();
     tire = okTable.Select(EAN);
     decimal price = tire.ProdejniCena;
     OrderTable tb = new OrderTable();
     int result = tb.InsertNewOrder(Cust_id, Empl_id, EAN, count, price);
     if(result > 0) Response.Redirect("~/Customers/Orders");
     else Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Něco je špatně');", true);
 }
    public void configure(CustomerDesc desc)
    {
        _desc = desc;

        _sprite = gameObject.AddComponent<tk2dAnimatedSprite>();
        ContentManager.instance.configureObject(_sprite, _desc.spriteAtlas, _desc.spriteName);
        Debug.Log("Old animation atlas - "+_desc.animationAtlas);
        ContentManager.instance.precacheAnimation(_sprite, _desc.animationAtlas);

        _currentMood = 100;
        _moodDownSpeed = 60f/desc.moodDownTime;

        GameObject tableGO = (GameObject)Instantiate((GameObject)Resources.Load("Prefabs/OrderTable"), Vector3.zero, Quaternion.identity);

        _orderTable = tableGO.GetComponent<OrderTable>();

        BoxCollider box = gameObject.AddComponent<BoxCollider>();
        box.size = new Vector3(_sprite.GetBounds().size.x, _sprite.GetBounds().size.y, 1);

        _sprite.Play("hello");

        setState(CustomerStateDeprecated.WAITING_STAND);
    }
Example #35
0
    protected void remove_selected_orders(int hblid)
    {
        if (this.dxlstSaved.Items.Count > 0 && hblid > 0)
        {
            try
            {
                //get  house bl details
                HouseBLTable _hbl = new HouseBLTable(hblid);  
                //DateTime? _nulldt = null; //use for clearing ets, eta if we need to
                
                //IList<string> _ordernos = new List<string>(); 
                OrderTableCollection _col = new OrderTableCollection();
                //step through selected list items and get order numbers
                for (int _ix = 0; _ix < this.dxlstSaved.Items.Count; _ix++)
                {
                    if (this.dxlstSaved.Items[_ix].Selected == true)
                    {
                        string _no = this.dxlstSaved.Items[_ix].Text.ToString();
                        //_ordernos.Add(_no); 
                        OrderTable _tbl = new OrderTable("OrderNumber", _no);

                        _tbl.HouseBLNUmber = null; //_h.HouseBLNumber;
                        _tbl.HouseBLAdded = false;
                        //_tbl.Ets = _nulldt;  //should we clear this? ms access db doesn't bother
                        //_tbl.Eta = _nulldt;  //should we clear this? ms access db doesn't bother
                        //_tbl.VesselLastUpdated = DateTime.Now; //should we clear this? ms access db doesn't bother

                        _col.Add(_tbl);
                    }//end if
                }//end loop

                //save 
                _col.SaveAll();

                //clear selected list and rebind other lists
                //saved orders list binding using hblnumber
                bind_housebl_orders(_hbl.HouseBLNumber.ToString());
                //available orders list binding
                bind_housebl_orders(wwi_func.vint(_hbl.ConsigneeID.ToString()), wwi_func.vint(_hbl.OriginPort.ToString()), wwi_func.vint(_hbl.DestinationPort.ToString()));
                //clear selected list
                this.dxlstSelected.Items.Clear();
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
    }
    //end update

    /// <summary>
    /// we won't need this as charges are in ordertable which must have key information saved before chrge allocations can be entered
    /// </summary>
    protected void insert_charges()
    {
        try
        {
            OrderTable _ot = new OrderTable();

            ASPxComboBox _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboClientsTerms");
            if (_cbo != null) { _ot.ClientsTerms = _cbo.Text.ToString(); }

            _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboOriginTrucking");
            if (_cbo != null) { _ot.OriginTrucking = _cbo.Text.ToString(); }

            _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboOrignTHC");
            if (_cbo != null) { _ot.OrignTHC = _cbo.Text.ToString(); }

            _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboOriginDocs");
            if (_cbo != null) { _ot.OriginDocs = _cbo.Text.ToString(); }

            _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboFreight");
            if (_cbo != null) { _ot.Freight = _cbo.Text.ToString(); }

            _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboDestTHC");
            if (_cbo != null) { _ot.DestTHC = _cbo.Text.ToString(); }

            _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboDestPalletisation");
            if (_cbo != null) { _ot.DestPalletisation = _cbo.Text.ToString(); }

            _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboCustomsClearance");
            if (_cbo != null) { _ot.CustomsClearance = _cbo.Text.ToString(); }

            _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboDeliveryCharges");
            if (_cbo != null) { _ot.DeliveryCharges = _cbo.Text.ToString(); }

            ASPxMemo _mem = (ASPxMemo)this.fmvCharge.FindControl("dxmemCoLoaderComments");
            if (_mem != null) { _ot.CoLoaderComments = _cbo.Text.ToString(); }

            _ot.Save();

            //return new order id
            Int32 _newid = (Int32)_ot.GetPrimaryKeyValue();
                            
            //confirm saved
            //string _msg = "Order " + _newid.ToString() + " has been updated";
            //this.dxlblOrderNo.Text = _newid.ToString(); 
            //this.dxlblInfo.Text = _msg;
            //this.dxpnlMsg.ClientVisible = true;
        }
        catch (Exception ex)
        {
            string _err = ex.Message.ToString();
            this.dxlblErr.Text = _err;
            this.dxpnlErr.ClientVisible = true;
        }
    }
    protected void update_charges()
    {
        try
        {
            int _orderid = wwi_func.vint(wwi_security.DecryptString(get_token("pid"), "publiship"));
            //Int32 _orderid = this.dxhfOrder.Contains("pid") ? wwi_func.vint(this.dxhfOrder.Get("pid").ToString()) : 0;
            if (_orderid > 0)
            {
                OrderTable _ot = new OrderTable(_orderid);

                ASPxComboBox _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboClientsTerms");
                if (_cbo != null) { _ot.ClientsTerms = _cbo.Text.ToString(); }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboOriginTrucking");
                if (_cbo != null) { _ot.OriginTrucking = _cbo.Text.ToString(); }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboOrignTHC");
                if (_cbo != null) { _ot.OrignTHC = _cbo.Text.ToString(); }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboOriginDocs");
                if (_cbo != null) { _ot.OriginDocs = _cbo.Text.ToString(); }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboFreight");
                if (_cbo != null) { _ot.Freight = _cbo.Text.ToString(); }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboDestTHC");
                if (_cbo != null) { _ot.DestTHC = _cbo.Text.ToString(); }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboDestPalletisation");
                if (_cbo != null) { _ot.DestPalletisation = _cbo.Text.ToString(); }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboCustomsClearance");
                if (_cbo != null) { _ot.CustomsClearance = _cbo.Text.ToString(); }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboDeliveryCharges");
                if (_cbo != null) { _ot.DeliveryCharges = _cbo.Text.ToString(); }

                ASPxMemo _mem = (ASPxMemo)this.fmvCharge.FindControl("dxmemCoLoaderComments");
                if (_mem != null) { _ot.CoLoaderComments = _mem.Text.ToString(); }
                
                _ot.Save();
                //confirm saved
                //string _msg = "Order " + this.dxlblOrderNo.Text.ToString() + " has been updated";
                //this.dxlblInfo.Text = _msg;
                //this.dxpnlMsg.ClientVisible = true;
            }
            else
            {
                string _err = "Unable to update charges. Order number not found.";
                this.dxlblErr.Text = _err;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        catch (Exception ex)
        {
            string _err = ex.Message.ToString();
            this.dxlblErr.Text = _err;
            this.dxpnlErr.ClientVisible = true;
        }
    }
    //end package type
    #endregion

    #region move container and orders
    /// <summary>
    /// move container to a different vessel
    /// 1. update Order table set VesselID = 'new vessel id', VesselLastUpdated = current date where containerid = N .Equivalent to access "ContainerVesselUpdateVesselQuery"
    /// 2. update Order table set ETS = VoyageETSSubTable.ETS, ETA=VoyageETSSubTable.ETA where containerid = N .Equivalent to access "ContainerVesselUpdateDatesQuery"
    /// 3. update Container table set VoyageID = 'new voyage id' where containerid = N .Equivalent to access ""ContainerVesselUpdateContainerQuery"
    /// </summary>
    /// <param name="containerid"></param>
    protected bool change_vessel(int containerid, int vesselid)
    {
        bool _changed = false;
        DateTime _currentdate = DateTime.Now;

        //for testing
        //containerid = 2332;

        using (SharedDbConnectionScope _sc = new SharedDbConnectionScope())
        {
            using (System.Transactions.TransactionScope _ts = new System.Transactions.TransactionScope())
            {
                try
                {
                    //for testing q1
                    //string _q1 = "SELECT o.OrderID, VesselId, VesselLastUpdated FROM OrderTable as o INNER JOIN  " + 
                    //"ContainerTable AS c INNER JOIN " +
                    //"ContainerSubTable AS s ON c.ContainerID = s.ContainerID ON o.OrderNumber = s.OrderNumber WHERE (c.ContainerID = 2332);";
                    //object[] _p1 = { containerid };
                    //int _result = new SubSonic.CodingHorror().ExecuteScalar<int>(_q1, _p1);
                    OrderTableCollection _q2 = new Select().From(DAL.Logistics.Tables.OrderTable)
                        .InnerJoin(DAL.Logistics.ContainerSubTable.OrderNumberColumn, DAL.Logistics.OrderTable.OrderNumberColumn)
                        .InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn)
                        .Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid).ExecuteAsCollection<OrderTableCollection>();

                    for (int _ix = 0; _ix < _q2.Count; _ix++)
                    {
                        _q2[_ix].VesselID = vesselid;
                        _q2[_ix].VesselLastUpdated = _currentdate;
            
                    }
                    _q2.SaveAll();
                    //does not work because the triggers on the ordertable cause errors 
                    //Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
                    //1st statement paramatised and using subsonic.codinghorror, table aliases prevent 'multi-part identifier can't be bound' tsql error
                    //string _q1 = "UPDATE OrderTable " +
                    //                "SET VesselID = @vesselid, VesselLastUpdated = @lastupdated " + 
                    //                "FROM OrderTable INNER JOIN " + 
                    //                "ContainerTable AS c INNER JOIN " + 
                    //                "ContainerSubTable AS s ON c.ContainerID = s.ContainerID ON OrderTable.OrderNumber = s.OrderNumber " + 
                    //                "WHERE (c.ContainerID = @containerid);";
                    //
                    //object[] _p1 = { vesselid, _currentdate,  containerid };
                    //int _result = new SubSonic.CodingHorror().ExecuteScalar<int>(_q1, _p1);

                    //for testing q2
                    //SELECT c.ContainerID, ets.ets, eta.eta, OrderTable.OrderID FROM ContainerTable AS c INNER JOIN 
                    //ContainerSubTable AS s ON c.ContainerID = s.ContainerID INNER JOIN 
                    //VoyageTable AS v INNER JOIN VoyageETASubTable AS eta ON v.VoyageID = eta.VoyageID 
                    //INNER JOIN VoyageETSSubTable AS ets ON v.VoyageID = ets.VoyageID INNER JOIN 
                    //OrderTable ON v.VoyageID = OrderTable.VesselID ON s.OrderNumber = OrderTable.OrderNumber
                    //WHERE (c.ContainerID = @containerid);
                    //object[] _p2 = { containerid };
                    //_result = new SubSonic.CodingHorror().ExecuteScalar<int>(_q2, _p2);
                    //q2
                    string[] _cols2 = { "OrderTable.OrderID", "VoyageETSSubTable.ETS", "VoyageETASubTable.ETA" };
                    DataTable _dt = new Select(_cols2).From(DAL.Logistics.Tables.OrderTable)
                    .InnerJoin(DAL.Logistics.ContainerSubTable.OrderIDColumn, DAL.Logistics.OrderTable.OrderIDColumn)
                    .InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn)
                    .InnerJoin(DAL.Logistics.VoyageTable.VoyageIDColumn, DAL.Logistics.OrderTable.VesselIDColumn)
                    .InnerJoin(DAL.Logistics.VoyageETSSubTable.VoyageIDColumn, DAL.Logistics.VoyageTable.VoyageIDColumn)
                    .InnerJoin(DAL.Logistics.VoyageETASubTable.VoyageIDColumn, DAL.Logistics.VoyageTable.VoyageIDColumn)
                    .Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid).ExecuteDataSet().Tables[0];

                    if (_dt.Rows.Count > 0)
                    {
                        OrderTableCollection _ot = new OrderTableCollection(); 
                        for (int _ix = 0; _ix < _dt.Rows.Count; _ix++)
                        {
                            int _id = wwi_func.vint(_dt.Rows[_ix]["OrderID"].ToString());
                            DateTime _ets = wwi_func.vdatetime(_dt.Rows[_ix]["Ets"].ToString());
                            DateTime _eta = wwi_func.vdatetime(_dt.Rows[_ix]["Eta"].ToString());
                            //update
                            OrderTable _tb = new OrderTable(_id);
                            _tb.Ets = _ets;
                            _tb.Eta = _eta;
                            _ot.Add(_tb); 
                        }
                        _ot.SaveAll(); 
                    }
                    //does not work because the triggers on the ordertable cause errors 
                    //2nd statement paramatised and using subsonic.codinghorror, table aliases prevent 'multi-part identifier can't be bound' tsql error
                    //string _q2 = "UPDATE OrderTable " + 
                    //                "SET ETS = ets.ETS, ETA = eta.ETA " + 
                    //                "FROM ContainerTable AS c INNER JOIN " + 
                    //                "ContainerSubTable AS s ON c.ContainerID = s.ContainerID INNER JOIN " + 
                    //                "VoyageTable AS v INNER JOIN " + 
                    //                "VoyageETASubTable AS eta ON v.VoyageID = eta.VoyageID INNER JOIN " + 
                    //                "VoyageETSSubTable AS ets ON v.VoyageID = ets.VoyageID INNER JOIN " + 
                    //                "OrderTable ON v.VoyageID = OrderTable.VesselID ON s.OrderNumber = OrderTable.OrderNumber " + 
                    //                "WHERE (c.ContainerID = @containerid);";
                    //object[] _p2 = { containerid };
                    //_result = new SubSonic.CodingHorror().ExecuteScalar<int>(_q2, _p2);
                    
                    //3rd statement 
                    Update _q3 = new Update(DAL.Logistics.Tables.ContainerTable);
                    _q3.Set(DAL.Logistics.ContainerTable.VoyageIDColumn).EqualTo(vesselid);
                    _q3.Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid);
                    //_test = _q3.ToString();
                    _q3.Execute();   


                    //commit transaction
                    _ts.Complete();

                    _changed = true;
                }
                catch (Exception ex)
                {
                    
                    string _er = ex.Message.ToString();
                    this.dxlblErr.Text = _er;
                    this.dxpnlErr.ClientVisible = true;
                }

            }
        }

        return _changed;
    }
    /// <summary>
    /// deprecated version
    /// </summary>
    /// <param name="containerid"></param>
    /// <param name="vesselid"></param>
    /// <returns></returns>
    protected bool change_vessel_deprecated(int containerid, int vesselid)
    {
        bool _changed = false;
        DateTime _currentdate = DateTime.Now;

        //for testing
        containerid = 2332;

        try
        {
            //for testing q1 ********
            //SqlQuery _s1 = new Select(DAL.Logistics.Tables.OrderTable);
            //_s1.InnerJoin(DAL.Logistics.ContainerSubTable.OrderIDColumn, DAL.Logistics.OrderTable.OrderIDColumn);
            //_s1.InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn);
            //_s1.Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid);
            //DataTable _dt1 = _s1.ExecuteDataSet().Tables[0];

            string[] _cols1 = { "OrderTable.OrderID", "OrderTable.VesselID", "OrderTable.VesselLastUpdated" };
            DataTable _dt = new Select(_cols1).From(DAL.Logistics.Tables.OrderTable)
            .InnerJoin(DAL.Logistics.ContainerSubTable.OrderIDColumn, DAL.Logistics.OrderTable.OrderIDColumn)
            .InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn)
            .Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid).ExecuteDataSet().Tables[0];
            
            if (_dt.Rows.Count > 0)
            {
                for (int _ix = 0; _ix < _dt.Rows.Count; _ix++)
                {
                    int _id = wwi_func.vint(_dt.Rows[_ix]["OrderID"].ToString());
                    //update
                    OrderTable _tb = new OrderTable(_id);
                    _tb.VesselID = vesselid;
                    _tb.VesselLastUpdated = _currentdate;
                    _tb.Save(); 
                }
            }
            
            
            //alternative method?
            //IList<int> _ids = new Select().From(DAL.Logistics.Tables.OrderTable)
            //.InnerJoin(DAL.Logistics.ContainerSubTable.OrderIDColumn, DAL.Logistics.OrderTable.OrderIDColumn)
            //.InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn)
            //.Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid).ExecuteTypedList<int>();
            //
            //IList<int> _q1 = new SubSonic.Update(DAL.Logistics.Tables.OrderTable)
            //    .Set(OrderTable.Columns.VesselID).EqualTo(vesselid)
            //    .Set(OrderTable.Columns.VesselLastUpdated).EqualTo(_currentdate)
            //    .Where(OrderTable.Columns.OrderID).In(_ids).ExecuteTypedList<int>();  
            
            //for testing q2 *******
            //Update _s2 = new Update(DAL.Logistics.Tables.OrderTable);
            //_s2.InnerJoin(DAL.Logistics.ContainerSubTable.OrderIDColumn, DAL.Logistics.OrderTable.OrderIDColumn);
            //_s2.InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn);
            //_s2.InnerJoin(DAL.Logistics.VoyageTable.VoyageIDColumn, DAL.Logistics.OrderTable.VesselIDColumn);
            //_s2.InnerJoin(DAL.Logistics.VoyageETSSubTable.VoyageIDColumn, DAL.Logistics.VoyageTable.VoyageIDColumn);
            //_s2.InnerJoin(DAL.Logistics.VoyageETASubTable.VoyageIDColumn, DAL.Logistics.VoyageTable.VoyageIDColumn);
            //_s2.Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid);
            //DataTable _dt2 = _s2.ExecuteDataSet().Tables[0];
            //**********************

            //can't use an update query here as there will likely be multiple orders to update and you will get 'multi-part identifier can't be bound'
            //get data with reader as we need the ETS and ETA values
            string[] _cols2 = { "OrderTable.OrderID", "VoyageETSSubTable.ETS", "VoyageETASubTable.ETA" };
            _dt = new Select(_cols2).From(DAL.Logistics.Tables.OrderTable)
            .InnerJoin(DAL.Logistics.ContainerSubTable.OrderIDColumn, DAL.Logistics.OrderTable.OrderIDColumn)
            .InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn)
            .InnerJoin(DAL.Logistics.VoyageTable.VoyageIDColumn, DAL.Logistics.OrderTable.VesselIDColumn)
            .InnerJoin(DAL.Logistics.VoyageETSSubTable.VoyageIDColumn, DAL.Logistics.VoyageTable.VoyageIDColumn)
            .InnerJoin(DAL.Logistics.VoyageETASubTable.VoyageIDColumn, DAL.Logistics.VoyageTable.VoyageIDColumn)
            .Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid).ExecuteDataSet().Tables[0];
 
            for (int _ix = 0; _ix < _dt.Rows.Count; _ix++)
            {
                int _id = wwi_func.vint(_dt.Rows[_ix]["OrderID"].ToString());
                DateTime _ets = wwi_func.vdatetime(_dt.Rows[_ix]["Ets"].ToString());
                DateTime _eta = wwi_func.vdatetime(_dt.Rows[_ix]["Eta"].ToString());
                //update
                OrderTable _tb = new OrderTable(_id);
                _tb.Ets = _ets;
                _tb.Eta = _eta;
                _tb.Save();
            }
            
            //can't do this as causes error multi-part identifier can't be bound
            //Update _q2 = new Update(DAL.Logistics.Tables.OrderTable);
            //    _q2.InnerJoin(DAL.Logistics.ContainerSubTable.OrderIDColumn, DAL.Logistics.OrderTable.OrderIDColumn);
            //    _q2.InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn);    
            //    _q2.InnerJoin(DAL.Logistics.VoyageTable.VoyageIDColumn, DAL.Logistics.OrderTable.VesselIDColumn);
            //    _q2.InnerJoin(DAL.Logistics.VoyageETSSubTable.VoyageIDColumn, DAL.Logistics.VoyageTable.VoyageIDColumn);
            //    _q2.InnerJoin(DAL.Logistics.VoyageETASubTable .VoyageIDColumn, DAL.Logistics.VoyageTable.VoyageIDColumn);
            //    _q2.Set(DAL.Logistics.OrderTable.EtsColumn).EqualTo(DAL.Logistics.VoyageETSSubTable.EtsColumn);
            //    _q2.Set(DAL.Logistics.OrderTable.EtaColumn).EqualTo(DAL.Logistics.VoyageETASubTable.EtaColumn);
            //    _q2.Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid);
            //_test = _q2.ToString();      
            //_q2.Execute();   

            //for testing q3 *******
            //SqlQuery _s3 = new Select(DAL.Logistics.Tables.ContainerTable);
            //_s3.Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid);
            //DataTable _dt3 = _s3.ExecuteDataSet().Tables[0];
            //**********************

            Update _q3 = new Update(DAL.Logistics.Tables.ContainerTable);
            _q3.Set(DAL.Logistics.ContainerTable.VoyageIDColumn).EqualTo(vesselid);
            _q3.Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid);
            //_test = _q3.ToString();
            _q3.Execute();   

            _changed = true;
        }
        catch (Exception ex)
        {
            string _er = ex.Message.ToString();
            this.dxlblErr.Text = _er;
            this.dxpnlErr.Visible = true;
        }

        return _changed;
    }
Example #40
0
    //end insert
#endregion

    #region db4objects persistence this code is not in use
    protected int? store_order_details()
    {
        //to use this code add these references to page and also enable static string for yapfile
        //using Db4objects.Db4o;
        //using Db4objects.Db4o.Config;
        //using Db4objects.Db4o.Query;

        int? _result = 0;
        //using ordertable class but saving to db4o
        OrderTable _t = new OrderTable();

        _t.OrderNumber = new Random().Next(int.MinValue, int.MaxValue); //temporary order number
        //dlls
        int? _intnull = null;
        ASPxComboBox _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboController");
        if (_cb != null) { _t.OrderControllerID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOps");
        if (_cb != null) { _t.OperationsControllerID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboCompany");
        if (_cb != null) { _t.CompanyID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboCountry");
        if (_cb != null) { _t.CountryID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOrigin");
        if (_cb != null) { _t.OriginPointID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOriginPort");
        if (_cb != null) { _t.PortID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboDestPort");
        if (_cb != null) { _t.DestinationPortID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboFinal");
        if (_cb != null) { _t.FinalDestinationID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboClientContact");
        if (_cb != null) { _t.ContactID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboPrinter");
        if (_cb != null) { _t.PrinterID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboAgentAtOrigin");
        if (_cb != null) { _t.AgentAtOriginID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOriginController");
        if (_cb != null) { _t.OriginPortControllerID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

        //dates
        DateTime? _dtnull = null; //default for nullable datetimes
        ASPxDateEdit _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtExWorks");
        if (_dt != null) { _t.ExWorksDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

        _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtCargoReady");
        if (_dt != null) { _t.CargoReady = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

        _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtWarehouse");
        if (_dt != null) { _t.WarehouseDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

        _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtBookingReceived");
        if (_dt != null) { _t.BookingReceived = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

        _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtDocsApproved");
        if (_dt != null) { _t.DocsApprovedDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

        //checkboxes
        ASPxCheckBox _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditJobPubliship");
        if (_ck != null) { _t.PublishipOrder = _ck.Checked; }

        //job closed not visible on this form
        //_ck = (ASPxCheckBox)this.formOrder.FindControl("dxckJobClosed");
        //if (_ck != null)
        //{
        //    //check if job has been closed in this append
        //    if (_t.JobClosed == false && _ck.Checked == true) { _t.JobClosureDate = DateTime.Now; }
        //    _t.JobClosed = _ck.Checked;
        //}

        _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditJobHot");
        if (_ck != null) { _t.HotJob = _ck.Checked; }

        _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditPalletised");
        if (_ck != null) { _t.Palletise = _ck.Checked ? -1 : 0; }

        _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditDocsAppr");
        if (_ck != null) { _t.DocsRcdAndApproved = _ck.Checked; }

        _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditIssueDl");
        if (_ck != null) { _t.ExpressBL = _ck.Checked; }

        _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditFumigation");
        if (_ck != null) { _t.FumigationCert = _ck.Checked; }

        _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditGSP");
        if (_ck != null) { _t.GSPCert = _ck.Checked; }

        _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditPacking");
        if (_ck != null) { _t.PackingDeclaration = _ck.Checked; }

        //memos
        ASPxMemo _mo = (ASPxMemo)this.formOrder.FindControl("dxmemoRemarksToCustomer");
        if (_mo != null) { _t.RemarksToCustomer = _mo.Text.ToString(); }

        _mo = (ASPxMemo)this.formOrder.FindControl("dxmemoRemarksToAgent");
        if (_mo != null) { _t.Remarks = _mo.Text.ToString(); }

        _mo = (ASPxMemo)this.formOrder.FindControl("dxmemoDocs");
        if (_mo != null) { _t.OtherDocsRequired = _mo.Text.ToString(); }

        //text boxes
        ASPxTextBox _tx = (ASPxTextBox)this.formOrder.FindControl("dxtxtCustomersRef");
        if (_tx != null) { _t.CustomersRef = _tx.Text.ToString(); }

        _tx = (ASPxTextBox)this.formOrder.FindControl("dxtxtSellingRate");
        if (_tx != null) { _t.Sellingrate = _tx.Text.ToString(); }

        _tx = (ASPxTextBox)this.formOrder.FindControl("dxtxtSellingAgent");
        if (_tx != null) { _t.SellingrateAgent = _tx.Text.ToString(); }

        //save to yap file
        //get userid to identify unique yap file name 
        //code disabled we aren't using it
        //string _userid = Page.Session["user"] != null ? ((UserClass)Page.Session["user"]).UserId.ToString() : "";
        //string _yap = string.Format(_yapfile, _userid);
        
        //delete any old db4object yap files 
        //File.Delete(_yapfile);

        //Db4objects.Db4o classes
        //using (IObjectContainer _db = Db4oEmbedded.OpenFile(_yap))
        //{
        //    _db.Store(_t);
        //}
        //end object
        _result = _t.OrderNumber;
        return _result;
    }
    protected void bind_formview(string mode)
    {
        string[] _key = { "OrderTemplateID" };
        OrderTemplateTableCollection _col = new OrderTemplateTableCollection();

        switch (mode){
            case "Insert":
                {
                    //blank template
                    OrderTemplateTable _template = new OrderTemplateTable();
                    _col.Add(_template);
                    break;
                }
            case "Edit":
                {
                    int _templateid = wwi_func.vint(wwi_security.DecryptString(get_token("pid"), "publiship"));
                    _col.Add(new OrderTemplateTable(_templateid));
                    break;
                }
            case "ReadOnly":
                {
                    //readonly check to see if an orderid has been passed as a param 'src'
                    //if it has populate template with data from selected order
                    int _orderid = wwi_func.vint(wwi_security.DecryptString(get_token("src"), "publiship"));
                    if (_orderid > 0)
                    {
                        //copy from order to template
                        OrderTable _order = new OrderTable(_orderid);
                        OrderTemplateTable _template = new OrderTemplateTable();
                        _template.PublishipOrder = _order.PublishipOrder;
                        _template.OfficeIndicator = _order.OfficeIndicator;
                        _template.CompanyID = _order.CompanyID;
                        _template.ConsigneeID = _order.ConsigneeID;
                        _template.NotifyPartyID = _order.NotifyPartyID;
                        _template.AgentAtOriginID = _order.AgentAtOriginID;
                        _template.AgentAtDestinationID = _order.AgentAtDestinationID;
                        _template.PrinterID = _order.PrinterID;
                        _template.ClearingAgentID = _order.ClearingAgentID;
                        _template.OnCarriageID = _order.OnCarriageID;
                        _template.OrderControllerID = _order.OrderControllerID;
                        _template.OperationsControllerID = _order.OperationsControllerID;
                        _template.OriginPortControllerID = _order.OriginPortControllerID;
                        _template.DestinationPortControllerID = _order.DestinationPortControllerID;
                        _template.CustomersRef = _order.CustomersRef;
                        _template.ContactID = _order.ContactID;
                        _template.OriginPointID = _order.OriginPointID;
                        _template.PortID = _order.PortID;
                        _template.DestinationPortID = _order.DestinationPortID;
                        _template.FinalDestinationID = _order.FinalDestinationID;
                        _template.CountryID = _order.CountryID;
                        _template.DestinationCountryID = _order.DestinationCountryID;
                        //add to collection
                        _col.Add(_template);
                    }
                    else
                    {
                        int _templateid = wwi_func.vint(wwi_security.DecryptString(get_token("pid"), "publiship"));
                        _col.Add(new OrderTemplateTable(_templateid));

                    }
                    break;
                }
            default:
                {
                    break;
                }
        }

        this.fmvTemplate.DataSource = _col;
        this.fmvTemplate.DataKeyNames = _key;
        this.fmvTemplate.DataBind(); 
    }
Example #42
0
    //end update

    /// <summary>
    /// append to order table
    /// 140114 replacing objectdatasource with code behind
    /// </summary>
    /// <param name="officeid">required so we can get next ordernumber from appropriate table</param>
    /// <returns></returns>
    protected int insert_order(int officeid, int newordernumber, string officeindicator)
    {
        //orderid of saved record
        int _newid = 0;
        
        try
        {
            if (newordernumber > 0)
            {
                OrderTable _t = new OrderTable();

                //defaults
                _t.OrderNumber = newordernumber;
                _t.OfficeIndicator = officeindicator;
                _t.DateOrderCreated = DateTime.Now;
                _t.EWDLastUpdated = DateTime.Now; //exworks last updated

                //dlls
                int? _intnull = null;
                ASPxComboBox _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboController");
                if (_cb != null) { _t.OrderControllerID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOps");
                if (_cb != null) { _t.OperationsControllerID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboCompany");
                if (_cb != null) { _t.CompanyID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboCountry");
                if (_cb != null) { _t.CountryID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOrigin");
                if (_cb != null) { _t.OriginPointID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOriginPort");
                if (_cb != null) { _t.PortID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboDestPort");
                if (_cb != null) { _t.DestinationPortID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboFinal");
                if (_cb != null) { _t.FinalDestinationID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboClientContact");
                if (_cb != null) { _t.ContactID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboPrinter");
                if (_cb != null) { _t.PrinterID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboAgentAtOrigin");
                if (_cb != null) { _t.AgentAtOriginID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOriginController");
                if (_cb != null) { _t.OriginPortControllerID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                //dates
                DateTime? _dtnull = null; //default for nullable datetimes
                ASPxDateEdit _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtExWorks");
                if (_dt != null) { _t.ExWorksDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

                _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtCargoReady");
                if (_dt != null) { _t.CargoReady = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

                _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtWarehouse");
                if (_dt != null) { _t.WarehouseDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

                _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtBookingReceived");
                if (_dt != null) { _t.BookingReceived = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

                _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtDocsApproved");
                if (_dt != null) { _t.DocsApprovedDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

                //checkboxes
                ASPxCheckBox _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditJobPubliship");
                if (_ck != null) { _t.PublishipOrder = _ck.Checked; }

                //job closed not visible on this form
                //_ck = (ASPxCheckBox)this.formOrder.FindControl("dxckJobClosed");
                //if (_ck != null)
                //{
                //    //check if job has been closed in this append
                //    if (_t.JobClosed == false && _ck.Checked == true) { _t.JobClosureDate = DateTime.Now; }
                //    _t.JobClosed = _ck.Checked;
                //}

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditJobHot");
                if (_ck != null) { _t.HotJob = _ck.Checked; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditPalletised");
                if (_ck != null) { _t.Palletise = _ck.Checked ? -1 : 0; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditDocsAppr");
                if (_ck != null) { _t.DocsRcdAndApproved = _ck.Checked; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditIssueDl");
                if (_ck != null) { _t.ExpressBL = _ck.Checked; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditFumigation");
                if (_ck != null) { _t.FumigationCert = _ck.Checked; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditGSP");
                if (_ck != null) { _t.GSPCert = _ck.Checked; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditPacking");
                if (_ck != null) { _t.PackingDeclaration = _ck.Checked; }

                //memos
                ASPxMemo _mo = (ASPxMemo)this.formOrder.FindControl("dxmemoRemarksToCustomer");
                if (_mo != null) { _t.RemarksToCustomer = _mo.Text.ToString(); }

                _mo = (ASPxMemo)this.formOrder.FindControl("dxmemoRemarksToAgent");
                if (_mo != null) { _t.Remarks = _mo.Text.ToString(); }

                _mo = (ASPxMemo)this.formOrder.FindControl("dxmemoDocs");
                if (_mo != null) { _t.OtherDocsRequired = _mo.Text.ToString(); }

                //text boxes
                ASPxTextBox _tx = (ASPxTextBox)this.formOrder.FindControl("dxtxtCustomersRef");
                if (_tx != null) { _t.CustomersRef = _tx.Text.ToString(); }

                _tx = (ASPxTextBox)this.formOrder.FindControl("dxtxtSellingRate");
                if (_tx != null) { _t.Sellingrate = _tx.Text.ToString(); }

                _tx = (ASPxTextBox)this.formOrder.FindControl("dxtxtSellingAgent");
                if (_tx != null) { _t.SellingrateAgent = _tx.Text.ToString(); }

                //append record
                _t.Save();
                //get new id
                _newid = (int)_t.GetPrimaryKeyValue();
            }
            else
            {
                string _ex = "Not able to find next Order Number";
                this.dxlblErr.Text = string.Format("Order NOT saved. Error: {0}", _ex);
                this.dxpnlErr.ClientVisible = true;
            }
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = string.Format("Order NOT saved. Error: {0}", _ex);
            this.dxpnlErr.ClientVisible = true;
        }

        return _newid;
    }
Example #43
0
    /// <summary>
    /// update order table
    /// 140114 replacing objectdatasource with code behind
    /// </summary>
    protected void update_order()
    {
        try
        {
            //use order id 303635 for testing purposes
            int _orderid = wwi_func.vint(wwi_security.DecryptString(get_token("pid"), "publiship"));
            
            if (_orderid > 0)
            {
                OrderTable _t = new OrderTable(_orderid);

                //dlls
                int? _intnull = null;
                ASPxComboBox _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboController");
                if (_cb != null) { _t.OrderControllerID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOps");
                if (_cb != null) { _t.OperationsControllerID =_cb.Value != null ? wwi_func.vint(_cb.Value.ToString()): _intnull; }
  
                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboCompany");
                if (_cb != null) { _t.CompanyID =  _cb.Value != null ?wwi_func.vint(_cb.Value.ToString()): _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboCountry");
                if (_cb != null) { _t.CountryID = _cb.Value != null ?wwi_func.vint(_cb.Value.ToString()): _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOrigin");
                if (_cb != null) { _t.OriginPointID =  _cb.Value != null ?wwi_func.vint(_cb.Value.ToString()): _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboOriginPort");
                if (_cb != null) { _t.PortID = _cb.Value != null ?wwi_func.vint(_cb.Value.ToString()): _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboDestPort");
                if (_cb != null) { _t.DestinationPortID =  _cb.Value != null ?wwi_func.vint(_cb.Value.ToString()): _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboFinal");
                if (_cb != null) { _t.FinalDestinationID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()): _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboClientContact");
                if (_cb != null) { _t.ContactID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()): _intnull; }

                _cb = (ASPxComboBox)this.formOrder.FindControl("dxcboPrinter");
                if (_cb != null) { _t.PrinterID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()): _intnull; }
                
                _cb= (ASPxComboBox)this.formOrder.FindControl("dxcboAgentAtOrigin");
                if (_cb != null) { _t.AgentAtOriginID = _cb.Value != null ?wwi_func.vint(_cb.Value.ToString()): _intnull; }
               
                _cb= (ASPxComboBox)this.formOrder.FindControl("dxcboOriginController");
                if (_cb != null) { _t.OriginPortControllerID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }
               
                //dates
                DateTime? _dtnull = null; //default for nullable datetimes
                ASPxDateEdit _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtExWorks");
                if (_dt != null) { _t.ExWorksDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()): _dtnull; } 
    
                _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtCargoReady");
                if (_dt != null) { _t.CargoReady = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }
                
                _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtWarehouse");
                if (_dt != null) { _t.WarehouseDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }
            
                _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtBookingReceived");
                if (_dt != null) { _t.BookingReceived = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }
            
                _dt = (ASPxDateEdit)this.formOrder.FindControl("dxdtDocsApproved");
                if (_dt != null) { _t.DocsApprovedDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Value.ToString()) : _dtnull; }

                //checkboxes
                ASPxCheckBox _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditJobPubliship");
                if (_ck != null) { _t.PublishipOrder = _ck.Checked; }

                //jobclosed not visible on this form
                //_ck = (ASPxCheckBox)this.formOrder.FindControl("dxckJobClosed");
                //if (_ck != null) { 
                //    //check if job has been closed in this update
                //    if (_t.JobClosed == false && _ck.Checked == true) { _t.JobClosureDate = DateTime.Now; }
                //    _t.JobClosed = _ck.Checked; 
                //}
                
                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditJobHot");
                if (_ck != null) { _t.HotJob = _ck.Checked; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditPalletised");
                if (_ck != null) { _t.Palletise = _ck.Checked? -1: 0; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditDocsAppr");
                if (_ck != null) { _t.DocsRcdAndApproved = _ck.Checked; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditIssueDl");
                if (_ck != null) { _t.ExpressBL = _ck.Checked; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditFumigation");
                if (_ck != null) { _t.FumigationCert = _ck.Checked; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditGSP");
                if (_ck != null) { _t.GSPCert = _ck.Checked; }

                _ck = (ASPxCheckBox)this.formOrder.FindControl("dxckEditPacking");
                if (_ck != null) { _t.PackingDeclaration = _ck.Checked; }
                
                //memos
                ASPxMemo _mo = (ASPxMemo)this.formOrder.FindControl("dxmemoRemarksToCustomer");
                if(_mo != null){ _t.RemarksToCustomer = _mo.Text.ToString(); }
                
                _mo = (ASPxMemo)this.formOrder.FindControl("dxmemoRemarksToAgent");
                if(_mo != null){ _t.Remarks = _mo.Text.ToString(); }
                
                _mo = (ASPxMemo)this.formOrder.FindControl("dxmemoDocs");
                if(_mo != null){ _t.OtherDocsRequired = _mo.Text.ToString(); }
                
                //text boxes
                ASPxTextBox _tx = (ASPxTextBox)this.formOrder.FindControl("dxtxtCustomersRef");   
                if(_tx != null){ _t.CustomersRef = _tx.Text.ToString(); }

                _tx = (ASPxTextBox)this.formOrder.FindControl("dxtxtSellingRate");   
                if(_tx != null){ _t.Sellingrate = _tx.Text.ToString(); }

                _tx = (ASPxTextBox)this.formOrder.FindControl("dxtxtSellingAgent");
                if (_tx != null) { _t.SellingrateAgent = _tx.Text.ToString(); }

                //update record
                _t.Save();
            }
        }
        catch (Exception ex)
        {
            string _orderno = wwi_security.DecryptString(get_token("pno"), "publiship");
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = string.Format("Order # {0} NOT updated. Error: {1}", _orderno ,  _ex);
            this.dxpnlErr.ClientVisible = true;
        }
    }
Example #44
0
 // Order?..
 public void pushOrderTable(OrderTable table)
 {
     _orderTables.Add(table);
 }
        public void PodUpdate(int OrderID, int OrderNumber, bool HotJob, int? CompanyID, int? AgentAtOriginID, int? PrinterID, int? OrderControllerID, int? OperationsControllerID, int? OriginPortControllerID, int? ContactID, DateTime? ExWorksDate, DateTime? CargoReady, DateTime? WarehouseDate, DateTime? BookingReceived, int? OriginPointID, int? PortID, int? DestinationPortID, int? FinalDestinationID, int? CountryID, int? Palletise, string RemarksToCustomer, bool DocsRcdAndApproved, DateTime? DocsApprovedDate, bool ExpressBL, bool FumigationCert, bool GSPCert, bool PackingDeclaration, string OtherDocsRequired)
        {
            //this is a fix for the issue: ods controller does not update nullable columns to null values
            //When using the Update method on ODSController (ie using GridView / FormView in an ASP.NET //application) and passing null values to nullable columns, the nullable column value remains //unchanged.
            //By creating an empty MyItem instance (all fields are null) and setting a nullable field to //null doesn' t allow the column to finish in the DirtyColumns collection (see ActiveHelper //GetUpdateCommand).
            //loading the specified record using key means MyItem instance is populated and so the nulled //column wil be dirty
            //OrderTable item = new OrderTable();
            OrderTable item = new OrderTable(OrderID);
            item.MarkOld();
            item.IsLoaded = true;

            item.OrderID = OrderID;

            item.OrderNumber = OrderNumber; //required field

            item.HotJob = HotJob;

            item.CompanyID = CompanyID;

            item.AgentAtOriginID = AgentAtOriginID;

            item.PrinterID = PrinterID;

            item.OrderControllerID = OrderControllerID;

            item.OperationsControllerID = OperationsControllerID;

            item.OriginPortControllerID = OriginPortControllerID;

            item.ContactID = ContactID;

            item.ExWorksDate = ExWorksDate;

            item.CargoReady = CargoReady;

            item.WarehouseDate = WarehouseDate;

            item.BookingReceived = BookingReceived;

            item.OriginPointID = OriginPointID;

            item.PortID = PortID;

            item.DestinationPortID = DestinationPortID;

            item.FinalDestinationID = FinalDestinationID;

            item.CountryID = CountryID;

            item.Palletise = Palletise;

            item.RemarksToCustomer = RemarksToCustomer;

            item.DocsRcdAndApproved = DocsRcdAndApproved;

            item.DocsApprovedDate = DocsApprovedDate;

            item.ExpressBL = ExpressBL;

            item.FumigationCert = FumigationCert;

            item.GSPCert = GSPCert;

            item.PackingDeclaration = PackingDeclaration;

            item.OtherDocsRequired = OtherDocsRequired;

            item.Save(UserName);
        }
        public void PodInsert(int? OrderNumber, string OfficeIndicator, bool PublishipOrder, DateTime? DateOrderCreated, bool HotJob, int? CompanyID, int? ConsigneeID, int? NotifyPartyID, int? AgentAtOriginID, int? AgentAtDestinationID, int? PrinterID, int? ClearingAgentID, int? OnCarriageID, int? OrderControllerID, int? OperationsControllerID, int? OriginPortControllerID, int? DestinationPortControllerID, string CustomersRef, int? ContactID, DateTime? ExWorksDate, DateTime? EWDLastUpdated, DateTime? CargoReady, DateTime? WarehouseDate, bool? OnTime, DateTime? BookingReceived, int? OriginPointID, int? PortID, int? DestinationPortID, int? FinalDestinationID, int? CountryID, string OldVesselName, int? DestinationCountryID, int? VesselID, DateTime? VesselLastUpdated, DateTime? Ets, DateTime? Eta, string PearsonDivCode, string PearsonSSRRef, string HouseBLNUmber, bool HouseBLAdded, bool ShippedOnBoard, float? EstCopies, DateTime? CopiesLastUpdated, int? EstCartons, int? EstPallets, int? EstWeight, float? EstVolume, int? Palletise, int? PackageTypeID, int? NumberOfPackages, int? ActualCartons, int? ActualPallets, int? Jackets, int? ActualWeight, DateTime? WeightLastUpdated, float? ActualVolume, DateTime? VolumeLastUpdated, bool? Fcllcl, int? Est20, int? Est40, int? EstLCLWt, float? EstLCLVol, int? No20, int? No40, int? LCLWt, float? LCLVol, string Remarks, string RemarksToCustomer, int? QuoteRef, string Sellingrate, string SellingrateAgent, bool DocsRcdAndApproved, DateTime? DocsApprovedDate, DateTime? JobClosureDate, bool JobClosed, bool ExpressBL, bool FumigationCert, bool GSPCert, bool COfO, bool PackingDeclaration, string OtherDocsRequired, string Incoterms, float? PricePerCopy, string Customs, string Currency, int? InvoiceAddresseeID, int? ConsolNumber, float? UnitPricePerCopy, bool OnHold, string ContainerInfo, DateTime? Cleared, float? HodderPricePerCopy, bool FileCoverPrintedOrigin, bool FileCoverPrintedDest, string ClientsTerms, string OriginTrucking, string OrignTHC, string OriginDocs, string Freight, string DestTHC, string DestPalletisation, string CustomsClearance, string DeliveryCharges, string CoLoaderComments, string Pdcid, string HCCompositeRef, decimal? HCInvoiceAmount, string Impression, decimal? InsuranceValue, double? InsuranceValues, int? InvoiceNumber, DateTime? InvoiceDate, DateTime? CancelRequestRcd, bool? OrderCancelled, DateTime? CancelDate, int? CancelledBy, int? InvoiceTo, decimal? HCInvoiceAmount2, bool? OrderAckSent, int? CargoUpdateId, int? QuoteId, int? DocumentFolder, byte[] Ts)
        {
            OrderTable item = new OrderTable();

            item.OrderNumber = OrderNumber;

            item.OfficeIndicator = OfficeIndicator;

            item.PublishipOrder = PublishipOrder;

            item.DateOrderCreated = DateOrderCreated;

            item.HotJob = HotJob;

            item.CompanyID = CompanyID;

            item.ConsigneeID = ConsigneeID;

            item.NotifyPartyID = NotifyPartyID;

            item.AgentAtOriginID = AgentAtOriginID;

            item.AgentAtDestinationID = AgentAtDestinationID;

            item.PrinterID = PrinterID;

            item.ClearingAgentID = ClearingAgentID;

            item.OnCarriageID = OnCarriageID;

            item.OrderControllerID = OrderControllerID;

            item.OperationsControllerID = OperationsControllerID;

            item.OriginPortControllerID = OriginPortControllerID;

            item.DestinationPortControllerID = DestinationPortControllerID;

            item.CustomersRef = CustomersRef;

            item.ContactID = ContactID;

            item.ExWorksDate = ExWorksDate;

            item.EWDLastUpdated = EWDLastUpdated;

            item.CargoReady = CargoReady;

            item.WarehouseDate = WarehouseDate;

            item.OnTime = OnTime;

            item.BookingReceived = BookingReceived;

            item.OriginPointID = OriginPointID;

            item.PortID = PortID;

            item.DestinationPortID = DestinationPortID;

            item.FinalDestinationID = FinalDestinationID;

            item.CountryID = CountryID;

            item.OldVesselName = OldVesselName;

            item.DestinationCountryID = DestinationCountryID;

            item.VesselID = VesselID;

            item.VesselLastUpdated = VesselLastUpdated;

            item.Ets = Ets;

            item.Eta = Eta;

            item.PearsonDivCode = PearsonDivCode;

            item.PearsonSSRRef = PearsonSSRRef;

            item.HouseBLNUmber = HouseBLNUmber;

            item.HouseBLAdded = HouseBLAdded;

            item.ShippedOnBoard = ShippedOnBoard;

            item.EstCopies = EstCopies;

            item.CopiesLastUpdated = CopiesLastUpdated;

            item.EstCartons = EstCartons;

            item.EstPallets = EstPallets;

            item.EstWeight = EstWeight;

            item.EstVolume = EstVolume;

            item.Palletise = Palletise;

            item.PackageTypeID = PackageTypeID;

            item.NumberOfPackages = NumberOfPackages;

            item.ActualCartons = ActualCartons;

            item.ActualPallets = ActualPallets;

            item.Jackets = Jackets;

            item.ActualWeight = ActualWeight;

            item.WeightLastUpdated = WeightLastUpdated;

            item.ActualVolume = ActualVolume;

            item.VolumeLastUpdated = VolumeLastUpdated;

            item.Fcllcl = Fcllcl;

            item.Est20 = Est20;

            item.Est40 = Est40;

            item.EstLCLWt = EstLCLWt;

            item.EstLCLVol = EstLCLVol;

            item.No20 = No20;

            item.No40 = No40;

            item.LCLWt = LCLWt;

            item.LCLVol = LCLVol;

            item.Remarks = Remarks;

            item.RemarksToCustomer = RemarksToCustomer;

            item.QuoteRef = QuoteRef;

            item.Sellingrate = Sellingrate;

            item.SellingrateAgent = SellingrateAgent;

            item.DocsRcdAndApproved = DocsRcdAndApproved;

            item.DocsApprovedDate = DocsApprovedDate;

            item.JobClosureDate = JobClosureDate;

            item.JobClosed = JobClosed;

            item.ExpressBL = ExpressBL;

            item.FumigationCert = FumigationCert;

            item.GSPCert = GSPCert;

            item.COfO = COfO;

            item.PackingDeclaration = PackingDeclaration;

            item.OtherDocsRequired = OtherDocsRequired;

            item.Incoterms = Incoterms;

            item.PricePerCopy = PricePerCopy;

            item.Customs = Customs;

            item.Currency = Currency;

            item.InvoiceAddresseeID = InvoiceAddresseeID;

            item.ConsolNumber = ConsolNumber;

            item.UnitPricePerCopy = UnitPricePerCopy;

            item.OnHold = OnHold;

            item.ContainerInfo = ContainerInfo;

            item.Cleared = Cleared;

            item.HodderPricePerCopy = HodderPricePerCopy;

            item.FileCoverPrintedOrigin = FileCoverPrintedOrigin;

            item.FileCoverPrintedDest = FileCoverPrintedDest;

            item.ClientsTerms = ClientsTerms;

            item.OriginTrucking = OriginTrucking;

            item.OrignTHC = OrignTHC;

            item.OriginDocs = OriginDocs;

            item.Freight = Freight;

            item.DestTHC = DestTHC;

            item.DestPalletisation = DestPalletisation;

            item.CustomsClearance = CustomsClearance;

            item.DeliveryCharges = DeliveryCharges;

            item.CoLoaderComments = CoLoaderComments;

            item.Pdcid = Pdcid;

            item.HCCompositeRef = HCCompositeRef;

            item.HCInvoiceAmount = HCInvoiceAmount;

            item.Impression = Impression;

            item.InsuranceValue = InsuranceValue;

            item.InsuranceValues = InsuranceValues;

            item.InvoiceNumber = InvoiceNumber;

            item.InvoiceDate = InvoiceDate;

            item.CancelRequestRcd = CancelRequestRcd;

            item.OrderCancelled = OrderCancelled;

            item.CancelDate = CancelDate;

            item.CancelledBy = CancelledBy;

            item.InvoiceTo = InvoiceTo;

            item.HCInvoiceAmount2 = HCInvoiceAmount2;

            item.OrderAckSent = OrderAckSent;

            item.CargoUpdateId = CargoUpdateId;

            item.QuoteId = QuoteId;

            item.DocumentFolder = DocumentFolder;

            item.Ts = Ts;


            item.Save(UserName);
        }
    }//end update

    /// <summary>
    /// we don't actually need an insert sub as shipment/vessel data is part of the ordertable which must have
    /// been saved before we get to shipment/vessel
    /// </summary>
    protected void insert_shipment()
    {
        try
        {
            //use order id 303635 for testing purposes
            int _orderid = wwi_func.vint(wwi_security.DecryptString(get_token("pid"), "publiship"));

            if (_orderid > 0)
            {
                OrderTable _t = new OrderTable(_orderid);

                //dlls
                //dlls
                int? _intnull = null;
                ASPxComboBox _cb = (ASPxComboBox)this.fmvShipment.FindControl("dxcboVesselID");
                if (_cb != null) { _t.VesselID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.fmvShipment.FindControl("dxcboPackageTypeID");
                if (_cb != null) { _t.PackageTypeID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }


                //why are the LCL/FCL values set to lcl=1, fcl=2 when the db data type is a bit? this doesn't make any sense
                //disbable code until confirmation from dave
                //_cb = (ASPxComboBox)this.fmvShipment.FindControl("dxcboFCLLCL");
                //if (_cb != null && _cb.Value != null) {
                //    string _lclfcl = _cb.Value.ToString();
                //    _t.Fcllcl = _lclfcl == "-1" ? true : false : false; //0 or -1
                //} 

                ASPxTextBox _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstPallets");
                if (_tx != null && _tx.Text != "") { _t.EstPallets = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstCartons");
                if (_tx != null && _tx.Text != "") { _t.EstCartons = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstWeight");
                if (_tx != null && _tx.Text != "") { _t.EstWeight = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstVolume");
                if (_tx != null && _tx.Text != "") { _t.EstVolume = wwi_func.vfloat(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstLCLWt");
                if (_tx != null && _tx.Text != "") { _t.EstLCLWt = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstLCLVol");
                if (_tx != null && _tx.Text != "") { _t.EstLCLVol = wwi_func.vfloat(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEst20");
                if (_tx != null && _tx.Text != "") { _t.Est20 = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEst40");
                if (_tx != null && _tx.Text != "") { _t.Est40 = wwi_func.vint(_tx.Text.ToString()); }

                //actuals
                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtActualWeight");
                if (_tx != null && _tx.Text != "") { _t.ActualWeight = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtActualVolume");
                if (_tx != null && _tx.Text != "") { _t.ActualVolume = wwi_func.vfloat(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtLCLWt");
                if (_tx != null && _tx.Text != "") { _t.LCLWt = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtLCLvol");
                if (_tx != null && _tx.Text != "") { _t.LCLVol = wwi_func.vfloat(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtActual20");
                if (_tx != null && _tx.Text != "") { _t.No20 = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtActual40");
                if (_tx != null && _tx.Text != "") { _t.No40 = wwi_func.vint(_tx.Text.ToString()); }

                //other
                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtNumberOfPackages");
                if (_tx != null && _tx.Text != "") { _t.NumberOfPackages = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtHouseBLNUmber");
                if (_tx != null && _tx.Text != "") { _t.HouseBLNUmber = _tx.Text.ToString(); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtJackets");
                if (_tx != null && _tx.Text != "") { _t.Jackets = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtConsolNumber");
                if (_tx != null && _tx.Text != "") { _t.ConsolNumber = wwi_func.vint(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtConsolNumber");
                if (_tx != null && _tx.Text != "") { _t.HodderPricePerCopy = wwi_func.vfloat(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtHCCompositeRef");
                if (_tx != null && _tx.Text != "") { _t.HCCompositeRef = _tx.Text.ToString(); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtHCInvoiceAmount2");
                if (_tx != null && _tx.Text != "") { _t.HCInvoiceAmount = wwi_func.vdecimal(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtInsuranceValue");
                if (_tx != null && _tx.Text != "") { _t.InsuranceValue = wwi_func.vdecimal(_tx.Text.ToString()); }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtImpression");
                if (_tx != null && _tx.Text != "") { _t.Impression = _tx.Text.ToString(); }

                //datetimes
                DateTime? _dtnull = null; //default for nullable datetimes
                ASPxDateEdit _dt = (ASPxDateEdit)this.fmvShipment.FindControl("dxdtETS");
                if (_dt != null) { _t.Ets = _dt.Value != null ? wwi_func.vdatetime(_dt.Date.ToString()) : _dtnull; }

                _dt = (ASPxDateEdit)this.fmvShipment.FindControl("dxdtETA");
                if (_dt != null) { _t.Eta = _dt.Value != null ? wwi_func.vdatetime(_dt.Date.ToString()) : _dtnull; }

                _dt = (ASPxDateEdit)this.fmvShipment.FindControl("dxdtJobClosureDate");
                if (_dt != null) { _t.JobClosureDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Date.ToString()) : _dtnull; }

                _dt = (ASPxDateEdit)this.fmvShipment.FindControl("dxdtWarehouseDate");
                if (_dt != null) { _t.WarehouseDate = _dt.Value != null ? wwi_func.vdatetime(_dt.Date.ToString()) : _dtnull; }

                //checkboxes
                ASPxCheckBox _ck = (ASPxCheckBox)this.fmvShipment.FindControl("dxckJobClosed");
                if (_ck != null) { _t.JobClosed = _ck.Checked; }

                _ck = (ASPxCheckBox)this.fmvShipment.FindControl("dxckOnBoard");
                if (_ck != null) { _t.ShippedOnBoard = _ck.Checked; }

                //update record
                _t.Save();
            }
        }
        catch (Exception ex)
        {
            string _orderno = wwi_security.DecryptString(get_token("pno"), "publiship");
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = string.Format("Order # {0} NOT updated. Error: {1}", _orderno, _ex);
            this.dxpnlErr.ClientVisible = true;
        }

    }//end insert
    //end update
    /// <summary>
    /// we don't really need an insert sub as address details can't be entered until main order details have been saved
    /// </summary>
    protected void insert_addresses()
    {
        try
        {
            //use order id 303635 for testing purposes
            int _orderid = wwi_func.vint(wwi_security.DecryptString(get_token("pid"), "publiship"));

            if (_orderid > 0)
            {
                OrderTable _t = new OrderTable(_orderid);

                //dlls
                int? _intnull = null;
                ASPxComboBox _cb = (ASPxComboBox)this.fmvAddresses.FindControl("dxcboConsigneeIDEdit");
                if (_cb != null) { _t.ConsigneeID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.fmvAddresses.FindControl("dxcboClearingAgentIDEdit");
                if (_cb != null) { _t.ClearingAgentID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.fmvAddresses.FindControl("dxcboAgentAtDestinationIDEdit");
                if (_cb != null) { _t.AgentAtDestinationID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.fmvAddresses.FindControl("dxcboNotifyPartyIDEdit");
                if (_cb != null) { _t.NotifyPartyID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.fmvAddresses.FindControl("dxcboOnCarriageIDEdit");
                if (_cb != null) { _t.OnCarriageID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                _cb = (ASPxComboBox)this.fmvAddresses.FindControl("dxcboDestinationPortControllerIDEdit");
                if (_cb != null) { _t.DestinationPortControllerID = _cb.Value != null ? wwi_func.vint(_cb.Value.ToString()) : _intnull; }

                //save record
                _t.Save();
            }
        }
        catch (Exception ex)
        {
            string _orderno = wwi_security.DecryptString(get_token("pno"), "publiship");
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = string.Format("Order # {0} NOT updated. Error: {1}", _orderno, _ex);
            this.dxpnlErr.ClientVisible = true;
        }
    }
    //end incremental filtering of printer
    #endregion

    #region crud events
    /// <summary>
    /// on save 
    /// copy order from ordertable to new record in ordertable
    /// </summary>
    protected int insert_clone(int orderid, int neworderno, string officeindicator)
    {
        int _newid = 0;
        
        try
        {
            //get order details we are cloning
            OrderTable _clone = new OrderTable(orderid); 
            
            //new order
            OrderTable _neworder = new OrderTable();
            //values changed from original order
            _neworder.DateOrderCreated = DateTime.Now;
            _neworder.OfficeIndicator = officeindicator;
            _neworder.OrderNumber = neworderno;

            //values derived from original order
            _neworder.PublishipOrder = _clone.PublishipOrder;
            _neworder.CompanyID = _clone.CompanyID;
            _neworder.ConsigneeID = _clone.ConsigneeID;
            _neworder.NotifyPartyID = _clone.NotifyPartyID;
            _neworder.AgentAtOriginID = _clone.AgentAtOriginID;
            _neworder.AgentAtDestinationID = _clone.AgentAtDestinationID;
            _neworder.PrinterID = _clone.PrinterID;
            _neworder.ClearingAgentID = _clone.ClearingAgentID;
            _neworder.OnCarriageID = _clone.OnCarriageID;
            _neworder.OrderControllerID = _clone.OrderControllerID;
            _neworder.OperationsControllerID = _clone.OperationsControllerID;
            _neworder.OriginPortControllerID = _clone.OriginPortControllerID;
            _neworder.DestinationPortControllerID = _clone.DestinationPortControllerID;
            _neworder.CustomersRef = _clone.CustomersRef;
            _neworder.ContactID = _clone.ContactID;
            _neworder.OriginPointID = _clone.OriginPointID;
            _neworder.PortID = _clone.PortID;
            _neworder.DestinationPortID = _clone.DestinationPortID;
            _neworder.FinalDestinationID = _clone.FinalDestinationID;
            _neworder.CountryID = _clone.CountryID;
            _neworder.DestinationCountryID = _clone.DestinationCountryID;

            _neworder.Save();

            _newid = (int)_neworder.GetPrimaryKeyValue();
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }

        return _newid;
    }
Example #50
0
    //end insert order number

    /// <summary>
    /// function to update order number in ordertable
    /// creates a new ordernumber in office table depending on officeid and updates specified order with this ordernumber
    /// </summary>
    /// <param name="orderid">from newly saved order on ordertable</param>
    /// <param name="officeid">from user profile or selected office</param>
    /// <returns></returns>
    public static int update_office_ordernumber(int orderid, int officeid)
    {
        int _newordernumber = 0;
        //get officeid, officeindicator - this will be used to determine the office indicator when the cloned order is saved
        //and it might be different to the original order depending on who is creating the clone
        //get new office indicator
        //using xml file for lookup at the officelookuptable in the database is not correctly configured (check with Dave re: fix)
        //make sure we have a default but it should come from lookup
        string _newoffice = wwi_func.lookup_xml_string("//xml//office_names.xml", "value", officeid.ToString(), "name", "UK Order");

        //create and return a new ordernumber from appropriate table
        _newordernumber = wwi_data.insert_order_number(officeid);
        //update the order just saved
        OrderTable _t = new OrderTable(orderid);
        _t.OrderNumber = _newordernumber;
        _t.OfficeIndicator = _newoffice;
        //update order
        _t.Save();
 
        return _newordernumber;
    }
    /// <summary>
    /// insert function for a template generated from a specified order
    /// </summary>
    /// <param name="orderid">int</param>
    /// <returns>int key id of new record</returns>
    protected int insert_order_from_template(int templateid, int neworderno, string newoffice)
    {
        int _newid = 0;
        //return next available orderno but just as a placeholder as it is required for appending the order
        //do not update actual orderno until new order is saved
       
        try
        {
            if (templateid > 0)
            {
                OrderTemplateTable _template = new OrderTemplateTable(templateid);
                //copy from template to order
                OrderTable _order = new OrderTable();

                _order.OrderNumber = neworderno;
                _order.OfficeIndicator = newoffice; //_template.OfficeIndicator;
                
                //copy details to order table 
                _order.PublishipOrder = (bool)_template.PublishipOrder;
                _order.CompanyID = _template.CompanyID;
                _order.ConsigneeID = _template.ConsigneeID;
                _order.NotifyPartyID = _template.NotifyPartyID;
                _order.AgentAtOriginID = _template.AgentAtOriginID;
                _order.AgentAtDestinationID = _template.AgentAtDestinationID;
                _order.PrinterID = _template.PrinterID;
                _order.ClearingAgentID = _template.ClearingAgentID;
                _order.OnCarriageID = _template.OnCarriageID;
                _order.OrderControllerID = _template.OrderControllerID;
                _order.OperationsControllerID = _template.OperationsControllerID;
                _order.OriginPortControllerID = _template.OriginPortControllerID;
                _order.DestinationPortControllerID = _template.DestinationPortControllerID;
                _order.CustomersRef = _template.CustomersRef;
                _order.ContactID = _template.ContactID;
                _order.OriginPointID = _template.OriginPointID;
                _order.PortID = _template.PortID;
                _order.DestinationPortID = _template.DestinationPortID;
                _order.FinalDestinationID = _template.FinalDestinationID;
                _order.CountryID = _template.CountryID;
                _order.DestinationCountryID = _template.DestinationCountryID;

                _order.DateOrderCreated = DateTime.Now;
                //save values
                _order.Save();

                _newid = (int)_order.GetPrimaryKeyValue();
            }
            else
            {
                string _ex = "Not able to create order. Template ID is 0";
                this.dxlblErr.Text = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }

        return _newid;
    }
    //end databound

    /// <summary>
    /// this code does not work for dynamically bound dlls which would need to be forced to bind on page load
    /// </summary>
    protected void set_defaults()
    {
        //is an order has been selected populate empty template from order details
        //else just use blank
        int _orderid = wwi_func.vint(wwi_security.DecryptString(get_token("src"), "publiship"));

        if (_orderid > 0)
        {
            //copy from order to template
            OrderTable _order = new OrderTable(_orderid);

            //set values from order
            //set office indicator
            //int _officeid = Session["user"] != null ? (int)((UserClass)Session["user"]).OfficeId : 1;
            //_template.OfficeIndicator = wwi_func.lookup_xml_string("xml\\office_names.xml", "value", _officeid.ToString(), "name");
            
            //_template.CustomersRef = _order.CustomersRef;
            ASPxTextBox _txt = (ASPxTextBox)this.fmvTemplate.FindControl("dxtxtCustomersRef");
            if (_txt != null) { _txt.Text = _order.CustomersRef; }
            //_template.PublishipOrder = _order.PublishipOrder;
            ASPxCheckBox _ckb = (ASPxCheckBox)this.fmvTemplate.FindControl("dxckbPublishipOrder");
            if (_ckb != null) { _ckb.Checked = _order.PublishipOrder; }
            //_template.OfficeIndicator = _order.OfficeIndicator;
            ASPxComboBox _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboOfficeIndicator");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.OfficeIndicator) ; }
            //_template.CompanyID = _order.CompanyID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboCompanyID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.CompanyID); }
            //_template.ConsigneeID = _order.ConsigneeID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboConsigneeID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.ConsigneeID); }
            //_template.NotifyPartyID = _order.NotifyPartyID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboNotifyPartyID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.NotifyPartyID); }
            //_template.AgentAtOriginID = _order.AgentAtOriginID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboAgentAtOriginID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.AgentAtOriginID); }
            //_template.AgentAtDestinationID = _order.AgentAtDestinationID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboAgentAtDestinationID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.AgentAtDestinationID); }
            //_template.PrinterID = _order.PrinterID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboPrinterID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.PrinterID); }
            //_template.ClearingAgentID = _order.ClearingAgentID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboClearingAgentID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.ClearingAgentID); }
            //_template.OnCarriageID = _order.OnCarriageID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboOnCarriageID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.OnCarriageID); }
            //_template.OrderControllerID = _order.OrderControllerID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboOrderControllerID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.OrderControllerID); }
            //_template.OperationsControllerID = _order.OperationsControllerID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboOperationsControllerID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.OperationsControllerID); }
            //_template.OriginPortControllerID = _order.OriginPortControllerID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboOriginPortControllerID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.OriginPortControllerID); }
            //_template.DestinationPortControllerID = _order.DestinationPortControllerID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboDestinationPortControllerID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.DestinationPortControllerID); }
            //_template.ContactID = _order.ContactID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboContactID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.ContactID); }
            //_template.OriginPointID = _order.OriginPointID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboOriginPointID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.OriginPointID); }
            //_template.PortID = _order.PortID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboPortID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.PortID); }
            //_template.DestinationPortID = _order.DestinationPortID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboDestinationPortID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.DestinationPortID); }
            //_template.FinalDestinationID = _order.FinalDestinationID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboFinalDestinationID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.FinalDestinationID); }
            //_template.CountryID = _order.CountryID;
            _cbo = (ASPxComboBox)this.fmvTemplate.FindControl("dxcboCountryID");
            if (_cbo != null) { _cbo.SelectedItem = _cbo.Items.FindByValue(_order.CountryID); }
        }
    }
    /// <summary>
    /// clone form is just ReadOnly we do not need any other functionality as it is for identical copies of an existing order
    /// if orderid is passed as param (pid) get data from order table
    /// </summary>
    /// <param name="ordertemplateid"></param>
    protected void bind_formview(int orderid)
    {
        string[] _key = { "OrderNumber" };
        CloneOrderTableCollection _col = new CloneOrderTableCollection();

        if (this.fmvTemplate.CurrentMode == FormViewMode.ReadOnly)
        {
            //blank template
            CloneOrderTable _clone = new CloneOrderTable();
 
            //create clone from selected order number (the clone table does not contain order id)
            int _orderid = wwi_func.vint(wwi_security.DecryptString(get_token("pid"), "publiship"));
            
            if (_orderid > 0)
            {
                //copy from order to template
                OrderTable _order = new OrderTable(_orderid);

                _clone.DateOrderCreated = DateTime.Now;
                _clone.PublishipOrder = _order.PublishipOrder;
                _clone.OfficeIndicator = _order.OfficeIndicator;
                _clone.CompanyID = _order.CompanyID;
                _clone.ConsigneeID = _order.ConsigneeID;
                _clone.NotifyPartyID = _order.NotifyPartyID;
                _clone.AgentAtOriginID = _order.AgentAtOriginID;
                _clone.AgentAtDestinationID = _order.AgentAtDestinationID;
                _clone.PrinterID = _order.PrinterID;
                _clone.ClearingAgentID = _order.ClearingAgentID;
                _clone.OnCarriageID = _order.OnCarriageID;
                _clone.OrderControllerID = _order.OrderControllerID;
                _clone.OperationsControllerID = _order.OperationsControllerID;
                _clone.OriginPortControllerID = _order.OriginPortControllerID;
                _clone.DestinationPortControllerID = _order.DestinationPortControllerID;
                _clone.CustomersRef = _order.CustomersRef;
                _clone.ContactID = _order.ContactID;
                _clone.OriginPointID = _order.OriginPointID;
                _clone.PortID = _order.PortID;
                _clone.DestinationPortID = _order.DestinationPortID;
                _clone.FinalDestinationID = _order.FinalDestinationID;
                _clone.CountryID = _order.CountryID;
                _clone.DestinationCountryID = _order.DestinationCountryID;
            }
            
            _col.Add(_clone);

            this.fmvTemplate.DataSource = _col;
            this.fmvTemplate.DataKeyNames = _key;
            this.fmvTemplate.DataBind(); 

        }
        else
        {
            //_col.Add(new CloneOrderTable());
            //error we must have an order number to clone from
            this.dxlblErr.Text = "No order number has been selected for cloning";
            this.dxpnlErr.ClientVisible = true;
        }
    }
    /// <summary>
    /// insert function for a template generated from a specified order
    /// </summary>
    /// <param name="orderid">int</param>
    /// <returns>int key id of new record</returns>
    protected int insert_template(int orderid)
    {
        int _newid = 0;
        string _newname = "";
        try
        {
            //check template name
            ASPxTextBox _txt = (ASPxTextBox)this.fmvTemplate.FindControl("dxtxtTemplateName");
            if (_txt != null) { _newname = _txt.Text; }

            if (!string.IsNullOrEmpty(_newname))
            {
                //copy from order to template
                OrderTable _order = new OrderTable(orderid);
                OrderTemplateTable _template = new OrderTemplateTable();

                _template.TemplateName = _newname;
                //copy details from order table 
                _template.PublishipOrder = _order.PublishipOrder;
                _template.OfficeIndicator = _order.OfficeIndicator;
                _template.CompanyID = _order.CompanyID;
                _template.ConsigneeID = _order.ConsigneeID;
                _template.NotifyPartyID = _order.NotifyPartyID;
                _template.AgentAtOriginID = _order.AgentAtOriginID;
                _template.AgentAtDestinationID = _order.AgentAtDestinationID;
                _template.PrinterID = _order.PrinterID;
                _template.ClearingAgentID = _order.ClearingAgentID;
                _template.OnCarriageID = _order.OnCarriageID;
                _template.OrderControllerID = _order.OrderControllerID;
                _template.OperationsControllerID = _order.OperationsControllerID;
                _template.OriginPortControllerID = _order.OriginPortControllerID;
                _template.DestinationPortControllerID = _order.DestinationPortControllerID;
                _template.CustomersRef = _order.CustomersRef;
                _template.ContactID = _order.ContactID;
                _template.OriginPointID = _order.OriginPointID;
                _template.PortID = _order.PortID;
                _template.DestinationPortID = _order.DestinationPortID;
                _template.FinalDestinationID = _order.FinalDestinationID;
                _template.CountryID = _order.CountryID;
                _template.DestinationCountryID = _order.DestinationCountryID;

                //save values
                _template.Save();

                _newid = (int)_template.GetPrimaryKeyValue();
            }
            else
            {
                string _ex = "You must enter a name for this template";
                this.dxlblErr.Text = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }

        return _newid;
    }