Exemple #1
0
    //end databound

    /// <summary>
    /// update hvoyagetable
    /// </summary>
    /// <param name="hblid">int</param>
    protected void update_voyage()
    {
        //voyageid
        int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));

        if (_pid > 0)
        {
            try
            {
                //new instance of record
                VoyageTable _tbl    = new VoyageTable(_pid);
                string      _joined = "";

                //get values off editform
                //vessel id
                ASPxComboBox _cbo = (ASPxComboBox)this.fmvVoyage.FindControl("dxcboVesselID");
                if (_cbo != null && _cbo.Value != null)
                {
                    _tbl.VesselID = wwi_func.vint(_cbo.Value.ToString());
                    _joined       = _cbo.Text.ToString();
                }

                //voyage number
                ASPxTextBox _txt = (ASPxTextBox)this.fmvVoyage.FindControl("dxtxtVoyageNumber");
                if (_txt != null)
                {
                    _tbl.VoyageNumber = _txt.Text.ToString();
                    _joined          += " " + _txt.Text.ToString();
                }

                //joined = vessel name & voyage number
                _tbl.Joined = _joined;
                //user
                _tbl.AddedBy = Page.Session["user"] != null ? (Int32)((UserClass)Page.Session["user"]).UserId : 0;
                //date
                _tbl.DateAdded = DateTime.Now;
                //update
                _tbl.Save();
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text          = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record VoyageId = 0";
            this.dxlblErr.Text          = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
Exemple #2
0
    //end update

    /// <summary>
    /// new record
    /// </summary>
    protected int insert_voyage()
    {
        int _newid = 0;

        try
        {
            ///new instance of record
            VoyageTable _tbl    = new VoyageTable();
            string      _joined = "";

            //get values off editform
            //vessel id
            ASPxComboBox _cbo = (ASPxComboBox)this.fmvVoyage.FindControl("dxcboVesselID");
            if (_cbo != null && _cbo.Value != null)
            {
                _tbl.VesselID = wwi_func.vint(_cbo.Value.ToString());
                _joined       = _cbo.Text.ToString();
            }

            //voyage number
            ASPxTextBox _txt = (ASPxTextBox)this.fmvVoyage.FindControl("dxtxtVoyageNumber");
            if (_txt != null)
            {
                _tbl.VoyageNumber = _txt.Text.ToString();
                _joined          += " " + _txt.Text.ToString();
            }

            //joined = vessel name & voyage number
            _tbl.Joined = _joined;
            //user
            _tbl.AddedBy = Page.Session["user"] != null ? (Int32)((UserClass)Page.Session["user"]).UserId : 0;
            //date
            _tbl.DateAdded = DateTime.Now;
            //insert
            _tbl.Save();
            //get new id
            _newid = (int)_tbl.GetPrimaryKeyValue();
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text          = _ex;
            this.dxpnlErr.ClientVisible = true;
        }

        return(_newid);
    }
    //end update

    /// <summary>
    /// new record
    /// </summary>
    protected int insert_voyage()
    {
        int _newid = 0;

        try
        {
            ///new instance of record
            VoyageTable _tbl = new VoyageTable();
            string _joined = "";

            //get values off editform
            //vessel id
            ASPxComboBox _cbo = (ASPxComboBox)this.fmvVoyage.FindControl("dxcboVesselID");
            if (_cbo != null && _cbo.Value != null)
            {
                _tbl.VesselID = wwi_func.vint(_cbo.Value.ToString());
                _joined = _cbo.Text.ToString();
            }

            //voyage number
            ASPxTextBox _txt = (ASPxTextBox)this.fmvVoyage.FindControl("dxtxtVoyageNumber");
            if (_txt != null)
            {
                _tbl.VoyageNumber = _txt.Text.ToString();
                _joined += " " + _txt.Text.ToString();
            }

            //joined = vessel name & voyage number
            _tbl.Joined = _joined;
            //user
            _tbl.AddedBy = Page.Session["user"] != null ? (Int32)((UserClass)Page.Session["user"]).UserId : 0;
            //date
            _tbl.DateAdded = DateTime.Now;
            //insert
            _tbl.Save();
            //get new id
            _newid = (int)_tbl.GetPrimaryKeyValue(); 
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
       
        return _newid;
    }
    //end databound

    /// <summary>
    /// update hvoyagetable
    /// </summary>
    /// <param name="hblid">int</param>
    protected void update_voyage()
    {
        //voyageid
        int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));

        if (_pid > 0)
        {
            try
            {
                //new instance of record
                VoyageTable _tbl = new VoyageTable(_pid);
                string _joined = "";

                //get values off editform
                //vessel id
                ASPxComboBox _cbo = (ASPxComboBox)this.fmvVoyage.FindControl("dxcboVesselID");
                if (_cbo != null && _cbo.Value != null) { 
                    _tbl.VesselID = wwi_func.vint(_cbo.Value.ToString());
                    _joined = _cbo.Text.ToString(); 
                }   

                //voyage number
                ASPxTextBox _txt = (ASPxTextBox)this.fmvVoyage.FindControl("dxtxtVoyageNumber");
                if (_txt != null) { 
                    _tbl.VoyageNumber = _txt.Text.ToString();
                    _joined += " " + _txt.Text.ToString();
                }
                
                //joined = vessel name & voyage number
                 _tbl.Joined =  _joined; 
                //user
                _tbl.AddedBy = Page.Session["user"] != null ? (Int32)((UserClass)Page.Session["user"]).UserId : 0;
                //date
                _tbl.DateAdded = DateTime.Now; 
                 //update
                _tbl.Save();
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record VoyageId = 0";
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
	    public void Insert(string VoyageNumber,int? VesselID,string Joined,int? AddedBy,DateTime? DateAdded,byte[] Ts)
	    {
		    VoyageTable item = new VoyageTable();
		    
            item.VoyageNumber = VoyageNumber;
            
            item.VesselID = VesselID;
            
            item.Joined = Joined;
            
            item.AddedBy = AddedBy;
            
            item.DateAdded = DateAdded;
            
            item.Ts = Ts;
            
	    
		    item.Save(UserName);
	    }
	    public void Update(int VoyageID,string VoyageNumber,int? VesselID,string Joined,int? AddedBy,DateTime? DateAdded,byte[] Ts)
	    {
		    VoyageTable item = new VoyageTable();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.VoyageID = VoyageID;
				
			item.VoyageNumber = VoyageNumber;
				
			item.VesselID = VesselID;
				
			item.Joined = Joined;
				
			item.AddedBy = AddedBy;
				
			item.DateAdded = DateAdded;
				
			item.Ts = Ts;
				
	        item.Save(UserName);
	    }