Exemplo n.º 1
0
    //end update

    protected int insert_container()
    {
        int _newid = 0;
        //for nullable values
        int? _intnull = null;
        DateTime? _dtnull = null;

        try
        {
            ContainerTable _tbl = new ContainerTable();
 
            ASPxTextBox _txt = (ASPxTextBox)this.fmvContainer.FindControl("dxtxtContainerNo");
            if (_txt != null) { _tbl.ContainerNumber = _txt.Text.ToString(); }

            ASPxComboBox _cbo = (ASPxComboBox)this.fmvContainer.FindControl("dxcboContainerStatus");
            if (_cbo != null) { _tbl.ContainerStatusID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; ; }

            _cbo = (ASPxComboBox)this.fmvContainer.FindControl("dxcboContainerType");
            if (_cbo != null) { _tbl.SizeTypeID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; ; }

            _cbo = (ASPxComboBox)this.fmvContainer.FindControl("dxcboVoyage");
            if (_cbo != null) { _tbl.VoyageID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; }

            _cbo = (ASPxComboBox)this.fmvContainer.FindControl("dxcboOriginPort");
            if (_cbo != null) { _tbl.OriginPortID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; }

            _cbo = (ASPxComboBox)this.fmvContainer.FindControl("dxcboDestPort");
            if (_cbo != null) { _tbl.DestinationPortID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; }

            _cbo = (ASPxComboBox)this.fmvContainer.FindControl("dxcboTerms");
            if (_cbo != null) { _tbl.Cycfs = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; }

            _cbo = (ASPxComboBox)this.fmvContainer.FindControl("dxcboWarehouse");
            if (_cbo != null) { _tbl.DevanWarehouseID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; }

            _cbo = (ASPxComboBox)this.fmvContainer.FindControl("dxcboOriginController");
            if (_cbo != null) { _tbl.OriginControllerID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; }

            _cbo = (ASPxComboBox)this.fmvContainer.FindControl("dxcboDestController");
            if (_cbo != null) { _tbl.DestinationControllerID = _cbo.Value != null? wwi_func.vint(_cbo.Value.ToString()): _intnull; }

            ASPxMemo _mem = (ASPxMemo)this.fmvContainer.FindControl("dxmemDevan");
            if (_mem != null) { _tbl.DevanNotes  = _mem.Text.ToString(); }

            ASPxCheckBox _ckb = (ASPxCheckBox)this.fmvContainer.FindControl("dxckDelivered");
            if (_ckb != null) { _tbl.Delivered = _ckb.Value != null? wwi_func.vbool(_ckb.Value.ToString()): false; }

            ASPxDateEdit _dte = (ASPxDateEdit)this.fmvContainer.FindControl("dxdtDeliveryDate");
            if (_dte != null) { _tbl.DeliveryDate = _dte.Value != null ? wwi_func.vdatetime(_dte.Value.ToString()) : _dtnull; }

            _ckb = (ASPxCheckBox)this.fmvContainer.FindControl("dxckDevanned");
            if (_ckb != null) { _tbl.Devanned = _ckb.Value != null? wwi_func.vbool(_ckb.Value.ToString()): false; }

            _dte = (ASPxDateEdit)this.fmvContainer.FindControl("dxdtDevanDate");
            if (_dte != null) { _tbl.DevanDate = _dte.Value != null ? wwi_func.vdatetime(_dte.Value.ToString()) : _dtnull; }

            _tbl.Save();

            //get new id
            _newid = (int)_tbl.GetPrimaryKeyValue(); 
        }
        catch (Exception _ex)
        {
            this.dxlblErr.Text = _ex.Message.ToString();
            this.dxpnlErr.ClientVisible = true;
        }

        return _newid;
    }