Esempio n. 1
0
    protected void bind_formview(string mode)
    {
        //have to use a collection as formview needs to bind to enumerable
        PackageTypeTableCollection _tbl = new PackageTypeTableCollection();

        if (mode != "Insert")
        {
            int _pid             = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
            PackageTypeTable _ct = new PackageTypeTable(_pid);
            _tbl.Add(_ct);

            //store original value for country name so we can check against database when saving
            if (this.dxhfOrder.Contains("oldvalue"))
            {
                this.dxhfOrder.Remove("oldvalue");
            }
            this.dxhfOrder.Add("oldvalue", _ct.PackageType);
        }
        else
        {
            PackageTypeTable _ct = new PackageTypeTable();
            _tbl.Add(_ct);
        }

        this.fmvPackage.DataSource = _tbl;
        this.fmvPackage.DataBind();
    }
	    public void Insert(string PackageType,byte[] Ts)
	    {
		    PackageTypeTable item = new PackageTypeTable();
		    
            item.PackageType = PackageType;
            
            item.Ts = Ts;
            
	    
		    item.Save(UserName);
	    }
Esempio n. 3
0
    /// <summary>
    /// update Place table
    /// </summary>
    /// <param name="hblid">int</param>
    protected void update_package_type()
    {
        //voyageid
        int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
        //original value for name
        string _oldvalue = this.dxhfOrder.Contains("oldvalue") ? this.dxhfOrder.Get("oldvalue").ToString() : "";

        if (_pid > 0)
        {
            try
            {
                //new instance of record
                PackageTypeTable _tbl = new PackageTypeTable(_pid);

                //get values off insert form
                //check duplicate name
                ASPxTextBox _txt = (ASPxTextBox)this.fmvPackage.FindControl("dxtxtPackageEdit");
                if (_txt != null && _txt.Text != "")
                {
                    string _newvalue  = _txt.Text.Trim().ToString(); //country name
                    bool   _duplicate = _newvalue != _oldvalue?wwi_func.value_exists("PackageType", "PackageTypeTable", _newvalue) : false;

                    if (!_duplicate)
                    {
                        _tbl.PackageType = _newvalue;
                        //update
                        _tbl.Save();
                    }
                    else
                    {
                        string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                        this.dxlblErr.Text          = _ex;
                        this.dxpnlErr.ClientVisible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text          = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record Country ID = 0";
            this.dxlblErr.Text          = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
Esempio n. 4
0
    //end update

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

        try
        {
            ///new instance of record
            PackageTypeTable _tbl = new PackageTypeTable();

            //get values off insert form
            //check for duplicate name
            ASPxTextBox _txt = (ASPxTextBox)this.fmvPackage.FindControl("dxtxtPackageInsert");
            if (_txt != null && _txt.Text != "")
            {
                string _newvalue = _txt.Text.Trim().ToString(); //country name

                if (!wwi_func.value_exists("PackageType", "PackageTypeTable", _newvalue))
                {
                    _tbl.PackageType = _txt.Text.Trim().ToString();
                    //insert
                    _tbl.Save();
                    //get new id
                    _newid = (int)_tbl.GetPrimaryKeyValue();
                }
                else
                {
                    string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                    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 update

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

        try
        {
            ///new instance of record
            PackageTypeTable _tbl = new PackageTypeTable();
            
            //get values off insert form
            //check for duplicate name
            ASPxTextBox _txt = (ASPxTextBox)this.fmvPackage.FindControl("dxtxtPackageInsert");
            if (_txt != null && _txt.Text != "")
            {
                string _newvalue = _txt.Text.Trim().ToString(); //country name

                if (!wwi_func.value_exists("PackageType", "PackageTypeTable", _newvalue))
                {
                    _tbl.PackageType = _txt.Text.Trim().ToString();
                    //insert
                    _tbl.Save();
                    //get new id
                    _newid = (int)_tbl.GetPrimaryKeyValue();
                }
                else
                {
                    string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                    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;
    }
    /// <summary>
    /// update Place table
    /// </summary>
    /// <param name="hblid">int</param>
    protected void update_package_type()
    {
        //voyageid
        int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
        //original value for name
        string _oldvalue = this.dxhfOrder.Contains("oldvalue") ? this.dxhfOrder.Get("oldvalue").ToString() : "";
   
        if (_pid > 0)
        {
            try
            {
                //new instance of record
                PackageTypeTable _tbl = new PackageTypeTable(_pid);

                //get values off insert form
                //check duplicate name
                ASPxTextBox _txt = (ASPxTextBox)this.fmvPackage.FindControl("dxtxtPackageEdit");
                if (_txt != null && _txt.Text != "")
                {  
                    string _newvalue = _txt.Text.Trim().ToString(); //country name
                    bool _duplicate = _newvalue != _oldvalue ? wwi_func.value_exists("PackageType", "PackageTypeTable", _newvalue) : false;

                    if (!_duplicate)
                    {
                        _tbl.PackageType  = _newvalue;
                        //update
                        _tbl.Save();
                    }
                    else
                    {
                        string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                        this.dxlblErr.Text = _ex;
                        this.dxpnlErr.ClientVisible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record Country ID = 0";
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
    protected void bind_formview(string mode)
    {
        //have to use a collection as formview needs to bind to enumerable
        PackageTypeTableCollection _tbl = new PackageTypeTableCollection();
        if (mode != "Insert")
        {
            int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
            PackageTypeTable _ct = new PackageTypeTable(_pid);
            _tbl.Add(_ct);

            //store original value for country name so we can check against database when saving
            if (this.dxhfOrder.Contains("oldvalue")) { this.dxhfOrder.Remove("oldvalue"); }
            this.dxhfOrder.Add("oldvalue", _ct.PackageType); 
        }
        else
        {
            PackageTypeTable _ct = new PackageTypeTable();
            _tbl.Add(_ct);
        }

        this.fmvPackage.DataSource = _tbl;
        this.fmvPackage.DataBind();
    }
	    public void Update(int PackageTypeID,string PackageType,byte[] Ts)
	    {
		    PackageTypeTable item = new PackageTypeTable();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.PackageTypeID = PackageTypeID;
				
			item.PackageType = PackageType;
				
			item.Ts = Ts;
				
	        item.Save(UserName);
	    }