protected void bind_formview(string mode) { //have to use a collection as formview needs to bind to enumerable PortTableCollection _tbl = new PortTableCollection(); if (mode != "Insert") { int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship")); PortTable _ct = new PortTable(_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.PortName); } else { PortTable _ct = new PortTable(); _tbl.Add(_ct); } this.fmvPort.DataSource = _tbl; this.fmvPort.DataBind(); }
/// <summary> /// update port table /// </summary> /// <param name="hblid">int</param> protected void update_port() { //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 PortTable _tbl = new PortTable(_pid); //get values off insert form //check duplicate name ASPxTextBox _txt = (ASPxTextBox)this.fmvPort.FindControl("dxtxtPortEdit"); if (_txt != null && _txt.Text != "") { string _newvalue = _txt.Text.Trim().ToString(); //country name bool _duplicate = _newvalue != _oldvalue?wwi_func.value_exists("PortName", "PortTable", _newvalue) : false; if (!_duplicate) { _tbl.PortName = _newvalue; //country id ASPxComboBox _cbo = (ASPxComboBox)this.fmvPort.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 PortName,int? CountryID,byte[] Ts) { PortTable item = new PortTable(); item.PortName = PortName; item.CountryID = CountryID; item.Ts = Ts; item.Save(UserName); }
//end update /// <summary> /// new record /// </summary> protected int insert_port() { int _newid = 0; try { ///new instance of record PortTable _tbl = new PortTable(); //get values off insert form //check for duplicate name ASPxTextBox _txt = (ASPxTextBox)this.fmvPort.FindControl("dxtxtPortInsert"); if (_txt != null && _txt.Text != "") { string _newvalue = _txt.Text.Trim().ToString(); //country name if (!wwi_func.value_exists("PortName", "PortTable", _newvalue)) { _tbl.PortName = _txt.Text.Trim().ToString(); //country id ASPxComboBox _cbo = (ASPxComboBox)this.fmvPort.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); }
public Server( Configuration owner, XmlNode server_node ) { Owner = owner; // -- XmlAttribute a = server_node.Attributes["isActive"]; if ( a!=null ) IsActive = Convert.ToBoolean(a.Value); a = server_node.Attributes["address"]; if ( a!=null ) Address = Convert.ToString(a.Value); // -- XmlNodeList ns = server_node.SelectNodes( "mailReceiverEMailAddresses/address" ); ArrayList l = new ArrayList( ns.Count ); foreach ( XmlNode n in ns ) { a = n.Attributes["address"]; if ( a!=null ) l.Add( Convert.ToString(a.Value) ); mailAdressList.Add(a.Value.ToString()); } EMailPortNotAvailableReceivers = (string[])l.ToArray( typeof(string) ); // -- ns = server_node.SelectNodes( "ports/port" ); l = new ArrayList( ns.Count ); foreach ( XmlNode n in ns ) { Port port = new Port( this, n ); l.Add( port ); PortTable.Add(((port.HasNumber)? port.Number.ToString(): port.NumberRangeBegin+"-"+port.NumberRangeEnd.ToString()),port); } Ports = (Port[])l.ToArray( typeof(Port) ); }
public void Update(int PortID,string PortName,int? CountryID,byte[] Ts) { PortTable item = new PortTable(); item.MarkOld(); item.IsLoaded = true; item.PortID = PortID; item.PortName = PortName; item.CountryID = CountryID; item.Ts = Ts; item.Save(UserName); }
//end update /// <summary> /// new record /// </summary> protected int insert_port() { int _newid = 0; try { ///new instance of record PortTable _tbl = new PortTable(); //get values off insert form //check for duplicate name ASPxTextBox _txt = (ASPxTextBox)this.fmvPort.FindControl("dxtxtPortInsert"); if (_txt != null && _txt.Text != "") { string _newvalue = _txt.Text.Trim().ToString(); //country name if (!wwi_func.value_exists("PortName", "PortTable", _newvalue)) { _tbl.PortName = _txt.Text.Trim().ToString(); //country id ASPxComboBox _cbo = (ASPxComboBox)this.fmvPort.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 port table /// </summary> /// <param name="hblid">int</param> protected void update_port() { //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 PortTable _tbl = new PortTable(_pid); //get values off insert form //check duplicate name ASPxTextBox _txt = (ASPxTextBox)this.fmvPort.FindControl("dxtxtPortEdit"); if (_txt != null && _txt.Text != "") { string _newvalue = _txt.Text.Trim().ToString(); //country name bool _duplicate = _newvalue != _oldvalue ? wwi_func.value_exists("PortName", "PortTable", _newvalue) : false; if (!_duplicate) { _tbl.PortName = _newvalue; //country id ASPxComboBox _cbo = (ASPxComboBox)this.fmvPort.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; } }
protected void bind_formview(string mode) { //have to use a collection as formview needs to bind to enumerable PortTableCollection _tbl = new PortTableCollection(); if (mode != "Insert") { int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship")); PortTable _ct = new PortTable(_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.PortName); } else { PortTable _ct = new PortTable(); _tbl.Add(_ct); } this.fmvPort.DataSource = _tbl; this.fmvPort.DataBind(); }