/// <summary>
    /// append to order table
    /// </summary>
    /// <returns>new record id of order 0 if failed</returns>
    protected Int32 append_order()
    {
        Int32 _newid = 0;
        DateTime? _dtnull = null;
        publishipadvanceOrderTableCustomcontroller _o = new publishipadvanceOrderTableCustomcontroller();
        int _len = this.dxmemaddress.Text.Length > 200 ? 200 : this.dxmemaddress.Text.Length;
        string _addr = wwi_func.no_sql(this.dxmemaddress.Text.ToString().Substring(0, _len));  
        string _dest = this.dxcbocountry.Text != null? this.dxcbocountry.Text.ToString(): "";
        DateTime? _cargo = this.dxdtcargoready.Text != ""? wwi_func.vdatetime(this.dxdtcargoready.Text): _dtnull;

        _newid = _o.PartialInsert(this.dxlblorderno2.Text, this.dxtxtpayee.Text, _addr, _dest, wwi_func.vint(this.dxlblprinter1.Text), wwi_func.vint(this.dxlblprinter2.Text),  _cargo , this.dxtxtfao.Text);
        this.dxhforder.Set("orderid", _newid.ToString());

        return _newid;
    }
    //****************************** end carton grid 
    /// <summary>
    /// set tallies for titles and cartons for current order and update order table
    /// </summary>
    /// <param name="orderid"></param>
    protected void set_tally(int orderId, int valueModifier, string appliesTo)
    {
        if (orderId > 0)
        {
            
            try
            {
                //Query q = new Query(DAL.Logistics.Tables.PublishipAdvanceOrderTable) {QueryType = QueryType.Update};
                //q.WHERE("OrderId", SubSonic.Comparison.Equals, orderId);
                //q.AddUpdateSetting(PublishipAdvanceOrderTable.Columns.Titles, 1);
  
                //update order table
                //PublishipAdvanceOrderTableCollection _o = new PublishipAdvanceOrderTableCollection().Where("OrderID", SubSonic.Comparison.Equals, orderId).Load();
                publishipadvanceOrderTableCustomcontroller _o = new publishipadvanceOrderTableCustomcontroller();

                switch (appliesTo)
                {
                        case "titles":
                            {
                                _o.UpdateTitleCount(orderId, valueModifier);  
                                break;
                            }
                        case "cartons":
                            {
                                _o.UpdateCartonCount(orderId, valueModifier);  
                                break;
                            }
                }

            }
            catch (Exception ex)
            {
                Response.Write(ex.Message.ToString()); 
            }
        }
    }