public void Insert(int? OrderNumber,int? DocsDespatchID,int? Original,DateTime? DocumentationDespatched,DateTime? DocsLastUpdated,string CourierName,string AWBNumber,bool SendByEmail,int? ContactID,string EmailAddress,byte[] Ts)
	    {
		    CourierDetailsSubTable item = new CourierDetailsSubTable();
		    
            item.OrderNumber = OrderNumber;
            
            item.DocsDespatchID = DocsDespatchID;
            
            item.Original = Original;
            
            item.DocumentationDespatched = DocumentationDespatched;
            
            item.DocsLastUpdated = DocsLastUpdated;
            
            item.CourierName = CourierName;
            
            item.AWBNumber = AWBNumber;
            
            item.SendByEmail = SendByEmail;
            
            item.ContactID = ContactID;
            
            item.EmailAddress = EmailAddress;
            
            item.Ts = Ts;
            
	    
		    item.Save(UserName);
	    }
    //end row inserting

    /// <summary>
    /// update courier
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dxgrdCourier_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView _grd = (ASPxGridView)sender;

        try
        {
            //courier details are joined to OrderTable on OrderNumber
            int _orderno = wwi_func.vint(wwi_security.DecryptString(get_token("pno"), "publiship"));

            int _courierid = wwi_func.vint(e.Keys["CourierDetailID"].ToString());   //get_courierdetailid();

            if (_orderno > 0 && _courierid > 0)
            {
                //get details
                CourierDetailsSubTable _t = new CourierDetailsSubTable(_courierid);

                //REQUIRED to line to ordertable
                _t.OrderNumber = _orderno;

                //radiobutton
                if (e.NewValues["Original"] != null) { _t.Original = wwi_func.vint(e.NewValues["Original"].ToString()); }

                //dlls
                if (e.NewValues["DocsDespatchID"] != null) { _t.DocsDespatchID = wwi_func.vint(e.NewValues["DocsDespatchID"].ToString()); }
                if (e.NewValues["ContactID"] != null) { _t.ContactID = wwi_func.vint(e.NewValues["ContactID"].ToString()); }

                //text boxes
                //courier or email depending on which text is visible
                if (e.NewValues["CourierName"] != null) { _t.CourierName = e.NewValues["CourierName"].ToString(); }
                if (e.NewValues["EmailAddress"] != null) { _t.EmailAddress = e.NewValues["EmailAddress"].ToString(); }
                if (e.NewValues["AWBNumber"] != null) { _t.AWBNumber = e.NewValues["AWBNumber"].ToString(); }

                //dates depending on which date is visible
                if (e.NewValues["DocumentationDespatched"] != null) { _t.DocumentationDespatched = wwi_func.vdatetime(e.NewValues["DocumentationDespatched"].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;
        }
        finally {
            //MUST call this after insert or error: Specified method is not supported
            e.Cancel = true;
            _grd.CancelEdit(); 
             bind_gridview(); 
        }
    }
    //end row inserting

    /// <summary>
    /// update courier
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dxgrdCourier_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView _grd = (ASPxGridView)sender;

        try
        {
            //courier details are joined to OrderTable on OrderNumber
            int _orderno = wwi_func.vint(wwi_security.DecryptString(get_token("pno"), "publiship"));

            int _courierid = wwi_func.vint(e.Keys["CourierDetailID"].ToString());   //get_courierdetailid();

            if (_orderno > 0 && _courierid > 0)
            {
                //get details
                CourierDetailsSubTable _t = new CourierDetailsSubTable(_courierid);

                //REQUIRED to line to ordertable
                _t.OrderNumber = _orderno;

                //radiobutton
                if (e.NewValues["Original"] != null)
                {
                    _t.Original = wwi_func.vint(e.NewValues["Original"].ToString());
                }

                //dlls
                if (e.NewValues["DocsDespatchID"] != null)
                {
                    _t.DocsDespatchID = wwi_func.vint(e.NewValues["DocsDespatchID"].ToString());
                }
                if (e.NewValues["ContactID"] != null)
                {
                    _t.ContactID = wwi_func.vint(e.NewValues["ContactID"].ToString());
                }

                //text boxes
                //courier or email depending on which text is visible
                if (e.NewValues["CourierName"] != null)
                {
                    _t.CourierName = e.NewValues["CourierName"].ToString();
                }
                if (e.NewValues["EmailAddress"] != null)
                {
                    _t.EmailAddress = e.NewValues["EmailAddress"].ToString();
                }
                if (e.NewValues["AWBNumber"] != null)
                {
                    _t.AWBNumber = e.NewValues["AWBNumber"].ToString();
                }

                //dates depending on which date is visible
                if (e.NewValues["DocumentationDespatched"] != null)
                {
                    _t.DocumentationDespatched = wwi_func.vdatetime(e.NewValues["DocumentationDespatched"].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;
        }
        finally {
            //MUST call this after insert or error: Specified method is not supported
            e.Cancel = true;
            _grd.CancelEdit();
            bind_gridview();
        }
    }