예제 #1
0
    //end update

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

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

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

                if (!wwi_func.value_exists("PlaceName", "PlacesTable", _newvalue))
                {
                    _tbl.PlaceName = _txt.Text.Trim().ToString();

                    //country id
                    ASPxComboBox _cbo = (ASPxComboBox)this.fmvPlace.FindControl("dxcboCountry");
                    if (_cbo != null && _cbo.Text != "")
                    {
                        _tbl.CountryID = wwi_func.vint(_cbo.Value.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);
    }
예제 #2
0
    //end update

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

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

                if (!wwi_func.value_exists("PlaceName", "PlacesTable", _newvalue))
                {
                    _tbl.PlaceName = _txt.Text.Trim().ToString();

                    //country id
                    ASPxComboBox _cbo = (ASPxComboBox)this.fmvPlace.FindControl("dxcboCountry");
                    if (_cbo != null && _cbo.Text != "")
                    {
                        _tbl.CountryID = wwi_func.vint(_cbo.Value.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;
    }