public void Insert(string HouseBLNumber,int? MasterBLID,int? ConsigneeID,DateTime? HBLDate,int? AgentAtDestinationID,int? OriginPort,int? DestinationPort,int? VoyageID,DateTime? Ets,DateTime? Eta,bool Added,byte[] Ts) { HouseBLTable item = new HouseBLTable(); item.HouseBLNumber = HouseBLNumber; item.MasterBLID = MasterBLID; item.ConsigneeID = ConsigneeID; item.HBLDate = HBLDate; item.AgentAtDestinationID = AgentAtDestinationID; item.OriginPort = OriginPort; item.DestinationPort = DestinationPort; item.VoyageID = VoyageID; item.Ets = Ets; item.Eta = Eta; item.Added = Added; item.Ts = Ts; item.Save(UserName); }
protected void bind_formview(string mode) { //try //{ //have to use a collection as formview needs to bind to enumerable HouseBLTableCollection _hbl = new HouseBLTableCollection(); if (mode != "Insert") { //get key id int _hblid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship")); HouseBLTable _tbl = new HouseBLTable(_hblid); _hbl.Add(_tbl); } else { HouseBLTable _tbl = new HouseBLTable(); _hbl.Add(_tbl); } this.fmvBol.DataSource = _hbl; this.fmvBol.DataBind(); //} //catch (Exception ex) //{ // this.dxlblErr.Text = ex.Message.ToString(); // this.dxpnlErr.ClientVisible = true; //} }
protected void remove_selected_orders(int hblid) { if (this.dxlstSaved.Items.Count > 0 && hblid > 0) { try { //get house bl details HouseBLTable _hbl = new HouseBLTable(hblid); //DateTime? _nulldt = null; //use for clearing ets, eta if we need to //IList<string> _ordernos = new List<string>(); OrderTableCollection _col = new OrderTableCollection(); //step through selected list items and get order numbers for (int _ix = 0; _ix < this.dxlstSaved.Items.Count; _ix++) { if (this.dxlstSaved.Items[_ix].Selected == true) { string _no = this.dxlstSaved.Items[_ix].Text.ToString(); //_ordernos.Add(_no); OrderTable _tbl = new OrderTable("OrderNumber", _no); _tbl.HouseBLNUmber = null; //_h.HouseBLNumber; _tbl.HouseBLAdded = false; //_tbl.Ets = _nulldt; //should we clear this? ms access db doesn't bother //_tbl.Eta = _nulldt; //should we clear this? ms access db doesn't bother //_tbl.VesselLastUpdated = DateTime.Now; //should we clear this? ms access db doesn't bother _col.Add(_tbl); } //end if } //end loop //save _col.SaveAll(); //clear selected list and rebind other lists //saved orders list binding using hblnumber bind_housebl_orders(_hbl.HouseBLNumber.ToString()); //available orders list binding bind_housebl_orders(wwi_func.vint(_hbl.ConsigneeID.ToString()), wwi_func.vint(_hbl.OriginPort.ToString()), wwi_func.vint(_hbl.DestinationPort.ToString())); //clear selected list this.dxlstSelected.Items.Clear(); } catch (Exception ex) { string _ex = ex.Message.ToString(); this.dxlblErr.Text = _ex; this.dxpnlErr.ClientVisible = true; } } }
//end update /// <summary> /// new record /// </summary> protected int insert_housebl() { int _newid = 0; try { //new instance of record HouseBLTable _hbl = new HouseBLTable(); //for nullable dates DateTime?_dtnull = null; //for nullable ints int?_intnull = null; //get values off editform //hbl number ASPxTextBox _txt = (ASPxTextBox)this.fmvBol.FindControl("dxtxtHouseBLNumber"); if (_txt != null) { _hbl.HouseBLNumber = _txt.Text.ToString(); } //hbl date ASPxDateEdit _dte = (ASPxDateEdit)this.fmvBol.FindControl("dxdtHBLdate"); //if (_dte != null) { _hbl.HBLDate = _dte.Date != null ? _dte.Date : _dtnull; } if (_dte != null && _dte.Value != null) { _hbl.HBLDate = _dte.Date; } //agent at destination ASPxComboBox _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboAgentAtDestinationID"); if (_cbo != null) { _hbl.AgentAtDestinationID = _cbo.Value != null?wwi_func.vint(_cbo.Value.ToString()) : _intnull; } //consignee _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboConsigneeID"); if (_cbo != null) { _hbl.ConsigneeID = _cbo.Value != null?wwi_func.vint(_cbo.Value.ToString()) : _intnull; } //vessel _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboVesselID"); if (_cbo != null) { _hbl.VoyageID = _cbo.Value != null?wwi_func.vint(_cbo.Value.ToString()) : _intnull; } //origin port _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboOriginPort"); if (_cbo != null) { _hbl.OriginPort = _cbo.Value != null?wwi_func.vint(_cbo.Value.ToString()) : _intnull; //ets we can't get it off label or use selecteditem.getvalue because label is updated client side _hbl.Ets = this.dxhfOrder.Contains("ets") ? wwi_func.vdatetime(this.dxhfOrder.Get("ets").ToString()) : _dtnull; //_hbl.Ets = _cbo.Value != null && _cbo.SelectedItem.GetValue("ETS") != null ? wwi_func.vdatetime(_cbo.SelectedItem.GetValue("ETS").ToString()) : _dtnull; } //ets //ASPxLabel _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblEtsSub"); //if (_lbl != null) { _hbl.Ets = wwi_func.vdatetime(_lbl.Text.ToString()); } //destination port _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboDestinationPort"); if (_cbo != null) { _hbl.DestinationPort = _cbo.Value != null?wwi_func.vint(_cbo.Value.ToString()) : _intnull; //ets we can't get it off label because they are updated client side _hbl.Eta = this.dxhfOrder.Contains("eta") ? wwi_func.vdatetime(this.dxhfOrder.Get("eta").ToString()) : _dtnull; //_hbl.Eta = _cbo.Value != null && _cbo.SelectedItem.GetValue("ETA") != null ? wwi_func.vdatetime(_cbo.SelectedItem.GetValue("ETA").ToString()) : _dtnull; } //eta //_lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblEtaSub"); //if (_lbl != null) { _hbl.Eta = wwi_func.vdatetime(_lbl.Text.ToString()); } //insert _hbl.Save(); //get new id _newid = (int)_hbl.GetPrimaryKeyValue(); } catch (Exception ex) { string _ex = ex.Message.ToString(); this.dxlblErr.Text = _ex; this.dxpnlErr.ClientVisible = true; } return(_newid); }
//end form binding /// <summary> /// on databound get data for dlls, etc /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void fmvBOL_DataBound(object sender, EventArgs e) { string _test = ""; HouseBLTable _t = (HouseBLTable)this.fmvBol.DataItem; //lookup values for readonly mode if (this.fmvBol.CurrentMode == FormViewMode.ReadOnly && _t != null) { this.dxlblStatus.Text = _t.HouseBLNumber.ToString(); //agent at destination _test = wwi_func.lookup_multi_values("CompanyName,Address1,Address2,Address3,CountryName,TelNo", "view_delivery_address", "CompanyID", _t.AgentAtDestinationID); string[] _lines = _test.Split(Environment.NewLine.ToCharArray()); //split returned string ASPxLabel _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblAgentAtDestinationIDView"); if (_lbl != null) { _lbl.Text = _lines[0].Trim(); } //company name _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblAgentAtDestinationIDSub"); //address if (_lbl != null) { _lbl.Text = _test.Replace(_lines[0], "").Trim(); } //consignee _test = wwi_func.lookup_multi_values("CompanyName,Address1,Address2,Address3,CountryName,TelNo", "view_delivery_address", "CompanyID", _t.ConsigneeID); _lines = _test.Split(Environment.NewLine.ToCharArray()); _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblConsigneeIDView"); if (_lbl != null) { _lbl.Text = _lines[0].Trim(); } //name _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblConsigneeIDSub"); if (_lbl != null && _test != "") { _lbl.Text = _test.Replace(_lines[0], "").Trim(); } //address //vessel _test = wwi_func.lookup_multi_values("Joined", "VoyageTable", "VoyageID", _t.VoyageID); _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblVoyageIDView"); if (_lbl != null) { _lbl.Text = _test; } //housebldate is databound just format it _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblHouseBLDateView"); if (_lbl != null) { _lbl.Text = wwi_func.vdatetime(_lbl.Text.ToString()).ToShortDateString(); } //ets is bound in bol table as well as voyage sub table //_test = wwi_func.lookup_value("ETS", "VoyageETSSubTable", "VoyageID", _t.VoyageID, true); _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblEtsSub"); if (_lbl != null) { _lbl.Text = _lbl.Text != ""? wwi_func.vdatetime(_lbl.Text).ToShortDateString(): ""; //add to hidden field this.dxhfOrder.Remove("ets"); this.dxhfOrder.Set("ets", _lbl.Text); } //eta is bound in bol table as well as voyage sub table //_test = wwi_func.lookup_value("ETA", "VoyageETASubTable", "VoyageID", _t.VoyageID, true); _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblEtaSub"); if (_lbl != null) { _lbl.Text = _lbl.Text != ""? wwi_func.vdatetime(_lbl.Text).ToShortDateString(): ""; //add to hidden field this.dxhfOrder.Remove("eta"); this.dxhfOrder.Set("eta", _lbl.Text); } //origin port and ets _test = wwi_func.lookup_value("PortName", "PortTable", "PortID", _t.OriginPort); _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblOriginPortView"); if (_lbl != null) { _lbl.Text = _test; } //destination port and eta _test = wwi_func.lookup_value("PortName", "PortTable", "PortID", _t.DestinationPort); _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblDestinationPortView"); if (_lbl != null) { _lbl.Text = _test; } //saved orders list binding using hblnumber bind_housebl_orders(_t.HouseBLNumber.ToString()); //available orders list binding bind_housebl_orders(wwi_func.vint(_t.ConsigneeID.ToString()), wwi_func.vint(_t.OriginPort.ToString()), wwi_func.vint(_t.DestinationPort.ToString())); } else if (this.fmvBol.CurrentMode == FormViewMode.Edit && _t != null) { this.dxlblStatus.Text = _t.HouseBLNumber.ToString(); string[] _fields = { "AgentAtDestinationID", "ConsigneeID" }; string _s = ""; //step through field names //get combobox value from dxcbo<fieldname>Edit //set address text on dxlbl<fieldname>Edit label for (int _ix = 0; _ix < _fields.Length; _ix++) { _s = ""; ASPxComboBox _cboCompany = (ASPxComboBox)this.fmvBol.FindControl("dxcbo" + _fields[_ix]); if (_cboCompany != null && _cboCompany.SelectedItem != null && _cboCompany.Value != null) { if (_cboCompany.SelectedItem.GetValue("Address1") != null) { _s = _s + (string)_cboCompany.SelectedItem.GetValue("Address1").ToString(); } //(string)_cboCompany.SelectedItem.Value.ToString(); _s += Environment.NewLine; if (_cboCompany.SelectedItem.GetValue("Address2") != null) { _s = _s + (string)_cboCompany.SelectedItem.GetValue("Address2").ToString(); } _s += Environment.NewLine; if (_cboCompany.SelectedItem.GetValue("Address3") != null) { _s = _s + (string)_cboCompany.SelectedItem.GetValue("Address3").ToString(); } _s += Environment.NewLine; if (_cboCompany.SelectedItem.GetValue("CountryName") != null) { _s = _s + (string)_cboCompany.SelectedItem.GetValue("CountryName").ToString(); } _s += Environment.NewLine; if (_cboCompany.SelectedItem.GetValue("TelNo") != null) { _s = _s + (string)_cboCompany.SelectedItem.GetValue("TelNo").ToString(); } _s += Environment.NewLine; } ASPxLabel _lblCompany = (ASPxLabel)this.fmvBol.FindControl("dxlbl" + _fields[_ix] + "Sub"); if (_lblCompany != null) { _lblCompany.Text = _s; } }//end loop ASPxComboBox _cbVoyage = (ASPxComboBox)this.fmvBol.FindControl("dxcboVoyageID"); if (_cbVoyage != null && _cbVoyage.SelectedItem != null && _cbVoyage.Value != null) { ASPxLabel _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblEtsSub"); if (_lbl != null) { _lbl.Text = _t.Ets != null?wwi_func.vdatetime(_t.Ets.ToString()).ToShortDateString() : ""; //add to hidden field this.dxhfOrder.Remove("ets"); this.dxhfOrder.Set("ets", _t.Ets); } //if (_lbl != null) { _lbl.Text = _cbVoyage.SelectedItem.GetValue("ETS") != null ? _cbVoyage.SelectedItem.GetValue("ETS").ToString() : ""; } _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblEtaSub"); if (_lbl != null) { _lbl.Text = _t.Eta != null?wwi_func.vdatetime(_t.Eta.ToString()).ToShortDateString() : ""; //add to hidden field this.dxhfOrder.Remove("eta"); this.dxhfOrder.Set("eta", _t.Eta); } //if (_lbl != null) { _lbl.Text = _cbVoyage.SelectedItem.GetValue("ETA") != null ? _cbVoyage.SelectedItem.GetValue("ETA").ToString() : ""; } }//endif //dll binding //get voyageid //int _id = 0; //ASPxComboBox _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboVoyageID"); //if (_cbo != null) { _id = wwi_func.vint(_cbo.SelectedItem.GetValue("VoyageID").ToString()); } int _voyageid = wwi_func.vint(_t.VoyageID.ToString()); bind_origin_port(_voyageid); bind_destination_port(_voyageid); //saved orders list binding using hblnumber bind_housebl_orders(_t.HouseBLNumber.ToString()); //available orders list binding bind_housebl_orders(wwi_func.vint(_t.ConsigneeID.ToString()), wwi_func.vint(_t.OriginPort.ToString()), wwi_func.vint(_t.DestinationPort.ToString())); } else if (this.fmvBol.CurrentMode == FormViewMode.Insert) { this.dxlblStatus.Text = "New record"; this.dxcbpOrderNumbers.Enabled = false; } //end formview mode }
protected void remove_selected_orders(int hblid) { if (this.dxlstSaved.Items.Count > 0 && hblid > 0) { try { //get house bl details HouseBLTable _hbl = new HouseBLTable(hblid); //DateTime? _nulldt = null; //use for clearing ets, eta if we need to //IList<string> _ordernos = new List<string>(); OrderTableCollection _col = new OrderTableCollection(); //step through selected list items and get order numbers for (int _ix = 0; _ix < this.dxlstSaved.Items.Count; _ix++) { if (this.dxlstSaved.Items[_ix].Selected == true) { string _no = this.dxlstSaved.Items[_ix].Text.ToString(); //_ordernos.Add(_no); OrderTable _tbl = new OrderTable("OrderNumber", _no); _tbl.HouseBLNUmber = null; //_h.HouseBLNumber; _tbl.HouseBLAdded = false; //_tbl.Ets = _nulldt; //should we clear this? ms access db doesn't bother //_tbl.Eta = _nulldt; //should we clear this? ms access db doesn't bother //_tbl.VesselLastUpdated = DateTime.Now; //should we clear this? ms access db doesn't bother _col.Add(_tbl); }//end if }//end loop //save _col.SaveAll(); //clear selected list and rebind other lists //saved orders list binding using hblnumber bind_housebl_orders(_hbl.HouseBLNumber.ToString()); //available orders list binding bind_housebl_orders(wwi_func.vint(_hbl.ConsigneeID.ToString()), wwi_func.vint(_hbl.OriginPort.ToString()), wwi_func.vint(_hbl.DestinationPort.ToString())); //clear selected list this.dxlstSelected.Items.Clear(); } catch (Exception ex) { string _ex = ex.Message.ToString(); this.dxlblErr.Text = _ex; this.dxpnlErr.ClientVisible = true; } } }
//end update /// <summary> /// new record /// </summary> protected int insert_housebl() { int _newid = 0; try { //new instance of record HouseBLTable _hbl = new HouseBLTable(); //for nullable dates DateTime? _dtnull = null; //for nullable ints int? _intnull = null; //get values off editform //hbl number ASPxTextBox _txt = (ASPxTextBox)this.fmvBol.FindControl("dxtxtHouseBLNumber"); if (_txt != null) { _hbl.HouseBLNumber = _txt.Text.ToString(); } //hbl date ASPxDateEdit _dte = (ASPxDateEdit)this.fmvBol.FindControl("dxdtHBLdate"); //if (_dte != null) { _hbl.HBLDate = _dte.Date != null ? _dte.Date : _dtnull; } if (_dte != null && _dte.Value != null) { _hbl.HBLDate = _dte.Date; } //agent at destination ASPxComboBox _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboAgentAtDestinationID"); if (_cbo != null) { _hbl.AgentAtDestinationID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; } //consignee _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboConsigneeID"); if (_cbo != null) { _hbl.ConsigneeID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; } //vessel _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboVesselID"); if (_cbo != null) { _hbl.VoyageID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; } //origin port _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboOriginPort"); if (_cbo != null) { _hbl.OriginPort = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; //ets we can't get it off label or use selecteditem.getvalue because label is updated client side _hbl.Ets = this.dxhfOrder.Contains("ets") ? wwi_func.vdatetime(this.dxhfOrder.Get("ets").ToString()) : _dtnull; //_hbl.Ets = _cbo.Value != null && _cbo.SelectedItem.GetValue("ETS") != null ? wwi_func.vdatetime(_cbo.SelectedItem.GetValue("ETS").ToString()) : _dtnull; } //ets //ASPxLabel _lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblEtsSub"); //if (_lbl != null) { _hbl.Ets = wwi_func.vdatetime(_lbl.Text.ToString()); } //destination port _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboDestinationPort"); if (_cbo != null) { _hbl.DestinationPort = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; //ets we can't get it off label because they are updated client side _hbl.Eta = this.dxhfOrder.Contains("eta") ? wwi_func.vdatetime(this.dxhfOrder.Get("eta").ToString()) : _dtnull; //_hbl.Eta = _cbo.Value != null && _cbo.SelectedItem.GetValue("ETA") != null ? wwi_func.vdatetime(_cbo.SelectedItem.GetValue("ETA").ToString()) : _dtnull; } //eta //_lbl = (ASPxLabel)this.fmvBol.FindControl("dxlblEtaSub"); //if (_lbl != null) { _hbl.Eta = wwi_func.vdatetime(_lbl.Text.ToString()); } //insert _hbl.Save(); //get new id _newid = (int)_hbl.GetPrimaryKeyValue(); } catch (Exception ex) { string _ex = ex.Message.ToString(); this.dxlblErr.Text = _ex; this.dxpnlErr.ClientVisible = true; } return _newid; }