//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; } }
//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); }
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); }
protected void bind_formview(string mode) { //have to use a collection as formview needs to bind to enumerable VoyageTableCollection _tbl = new VoyageTableCollection(); if (mode != "Insert") { int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship")); VoyageTable _vt = new VoyageTable(_pid); _tbl.Add(_vt); } else { VoyageTable _vt = new VoyageTable(); _tbl.Add(_vt); } this.fmvVoyage.DataSource = _tbl; this.fmvVoyage.DataBind(); }
//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; }
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); }
protected void fmvVoyage_DataBound(object sender, EventArgs e) { string _test = ""; VoyageTable _t = (VoyageTable)this.fmvVoyage.DataItem; //voyage id is also added as encryped primary key number to hiddenfields on page load this.dxlblID.Text = this.fmvVoyage.CurrentMode == FormViewMode.Insert ? "New voyage" : _t.Joined != null?_t.Joined.ToString() : ""; //lookup values for readonly mode if (this.fmvVoyage.CurrentMode == FormViewMode.ReadOnly) { //vessel name _test = wwi_func.lookup_value("VesselName", "VesselTable", "VesselID", _t.VesselID); ASPxLabel _lbl = (ASPxLabel)this.fmvVoyage.FindControl("dxlblVesselIDView"); if (_lbl != null) { _lbl.Text = _test; } //added by _test = wwi_func.lookup_value("Name", "EmployeesTable", "EmployeeID", _t.AddedBy); _lbl = (ASPxLabel)this.fmvVoyage.FindControl("dxlblAddedByView"); if (_lbl != null) { _lbl.Text = _test; } } else if (this.fmvVoyage.CurrentMode == FormViewMode.Edit) { //vessel name is bound to linqdatasource //added by _test = wwi_func.lookup_value("Name", "EmployeesTable", "EmployeeID", _t.AddedBy); ASPxLabel _lbl = (ASPxLabel)this.fmvVoyage.FindControl("dxlblAddedByName"); if (_lbl != null) { _lbl.Text = _test; } } else //insert { //vessel name is bound to linqdatasource //set addedby and added date just for appearance as we save the userid not the name in voyagetable ASPxLabel _lbl = (ASPxLabel)this.fmvVoyage.FindControl("dxlblAddedByName"); if (_lbl != null) { _lbl.Text = Page.Session["user"] != null ? (string)((UserClass)Page.Session["user"]).UserName: ""; } _lbl = (ASPxLabel)this.fmvVoyage.FindControl("dxlblDateAddedView"); if (_lbl != null) { _lbl.Text = DateTime.Now.ToShortDateString(); } //not needed, this is set automatically. dll binding just for added by as vessel is bound dynamically //bind_added_by(); } if (_t != null) { //bind ets, eta grids on VoyageID bind_ets_grid(_t.VoyageID); bind_eta_grid(_t.VoyageID); //we need these values for crud events on ets/eta grids. They can also be changed client-side this.dxhfOrder.Remove("voyage"); this.dxhfOrder.Set("voyage", _t.VoyageID); this.dxhfOrder.Remove("vessel"); this.dxhfOrder.Set("vessel", _t.VesselID); } }