/// <summary> /// update Place table /// </summary> /// <param name="hblid">int</param> protected void update_place() { //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 PlacesTable _tbl = new PlacesTable(_pid); //get values off insert form //check duplicate name ASPxTextBox _txt = (ASPxTextBox)this.fmvPlace.FindControl("dxtxtPlaceEdit"); if (_txt != null && _txt.Text != "") { string _newvalue = _txt.Text.Trim().ToString(); //country name bool _duplicate = _newvalue != _oldvalue?wwi_func.value_exists("PlaceName", "PlacesTable", _newvalue) : false; if (!_duplicate) { _tbl.PlaceName = _newvalue; //country id ASPxComboBox _cbo = (ASPxComboBox)this.fmvPlace.FindControl("dxcboCountry"); if (_cbo != null && _cbo.Text != "") { _tbl.CountryID = wwi_func.vint(_cbo.Value.ToString()); } //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; } }
//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); }
//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; }
/// <summary> /// update Place table /// </summary> /// <param name="hblid">int</param> protected void update_place() { //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 PlacesTable _tbl = new PlacesTable(_pid); //get values off insert form //check duplicate name ASPxTextBox _txt = (ASPxTextBox)this.fmvPlace.FindControl("dxtxtPlaceEdit"); if (_txt != null && _txt.Text != "") { string _newvalue = _txt.Text.Trim().ToString(); //country name bool _duplicate = _newvalue != _oldvalue ? wwi_func.value_exists("PlaceName", "PlacesTable", _newvalue) : false; if (!_duplicate) { _tbl.PlaceName = _newvalue; //country id ASPxComboBox _cbo = (ASPxComboBox)this.fmvPlace.FindControl("dxcboCountry"); if (_cbo != null && _cbo.Text != "") { _tbl.CountryID = wwi_func.vint(_cbo.Value.ToString()); } //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; } }
public void Insert(string PlaceName,int? CountryID,int? DefaultPalletID,byte[] Ts) { PlacesTable item = new PlacesTable(); item.PlaceName = PlaceName; item.CountryID = CountryID; item.DefaultPalletID = DefaultPalletID; item.Ts = Ts; item.Save(UserName); }
public void Update(int PlaceID,string PlaceName,int? CountryID,int? DefaultPalletID,byte[] Ts) { PlacesTable item = new PlacesTable(); item.MarkOld(); item.IsLoaded = true; item.PlaceID = PlaceID; item.PlaceName = PlaceName; item.CountryID = CountryID; item.DefaultPalletID = DefaultPalletID; item.Ts = Ts; item.Save(UserName); }