Example #1
0
    /// <summary>
    /// insert event for ETS grid
    /// save to VoyageETSSubTable
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dxgrdETS_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxGridView _grd    = (ASPxGridView)sender;
        DateTime?    _dtnull = null;

        int _voyageid = this.dxhfOrder.Contains("voyage") ? wwi_func.vint(this.dxhfOrder.Get("voyage").ToString()): 0;
        int _vesselid = this.dxhfOrder.Contains("vessel") ? wwi_func.vint(this.dxhfOrder.Get("vessel").ToString()) : 0;
        int _portid   = e.NewValues["OriginPortID"] != null?wwi_func.vint(e.NewValues["OriginPortID"].ToString()) : 0;

        DateTime?_dtets = e.NewValues["ETS"] != null?wwi_func.vdatetime(e.NewValues["ETS"].ToString()) : _dtnull;

        if (_voyageid > 0)
        {
            VoyageETSSubTable _tbl = new VoyageETSSubTable();
            _tbl.VoyageID     = _voyageid;
            _tbl.OriginPortID = _portid;
            _tbl.Ets          = _dtets;
            _tbl.Save();

            if (_portid > 0 && _vesselid > 0)
            {
                update_ordertable_ets(_portid, _vesselid, _dtets);
            }
        }
        //MUST call this after insert or error: Specified method is not supported
        e.Cancel = true;
        _grd.CancelEdit();
        //rebind
        bind_ets_grid(_voyageid);
    }
	    public void Insert(int? VoyageID,int? OriginPortID,DateTime? Ets,byte[] Ts)
	    {
		    VoyageETSSubTable item = new VoyageETSSubTable();
		    
            item.VoyageID = VoyageID;
            
            item.OriginPortID = OriginPortID;
            
            item.Ets = Ets;
            
            item.Ts = Ts;
            
	    
		    item.Save(UserName);
	    }
        public void Insert(int?VoyageID, int?OriginPortID, DateTime?Ets, byte[] Ts)
        {
            VoyageETSSubTable item = new VoyageETSSubTable();

            item.VoyageID = VoyageID;

            item.OriginPortID = OriginPortID;

            item.Ets = Ets;

            item.Ts = Ts;


            item.Save(UserName);
        }
Example #4
0
    //end ets row updating

    /// <summary>
    /// delete row
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dxgrdETS_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
    {
        ASPxGridView _grd      = (ASPxGridView)sender;
        int          _voyageid = this.dxhfOrder.Contains("voyage") ? wwi_func.vint(this.dxhfOrder.Get("voyage").ToString()) : 0;


        int _etsid = e.Keys["VoyageETSSubID"] != null?wwi_func.vint(e.Keys["VoyageETSSubID"].ToString()) : 0;

        if (_etsid > 0)
        {
            VoyageETSSubTable.Delete(_etsid);
        }
        //MUST call this after insert or error: Specified method is not supported
        e.Cancel = true;
        _grd.CancelEdit();
        //rebind
        bind_ets_grid(_voyageid);
    }
        public void Update(int VoyageETSSubID, int?VoyageID, int?OriginPortID, DateTime?Ets, byte[] Ts)
        {
            VoyageETSSubTable item = new VoyageETSSubTable();

            item.MarkOld();
            item.IsLoaded = true;

            item.VoyageETSSubID = VoyageETSSubID;

            item.VoyageID = VoyageID;

            item.OriginPortID = OriginPortID;

            item.Ets = Ets;

            item.Ts = Ts;

            item.Save(UserName);
        }
	    public void Update(int VoyageETSSubID,int? VoyageID,int? OriginPortID,DateTime? Ets,byte[] Ts)
	    {
		    VoyageETSSubTable item = new VoyageETSSubTable();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.VoyageETSSubID = VoyageETSSubID;
				
			item.VoyageID = VoyageID;
				
			item.OriginPortID = OriginPortID;
				
			item.Ets = Ets;
				
			item.Ts = Ts;
				
	        item.Save(UserName);
	    }
Example #7
0
    /// <summary>
    /// update event for ETS grid
    /// check DATE. if it's been changed will need to update order table
    /// ordertable.ETS = new ETS, ordertable.VesselLastUpdated = now where ordertable.PortID = OriginPortID and ordertable.VesselID = VesselID
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dxgrdETS_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView _grd = (ASPxGridView)sender;
        
        int _voyageid = this.dxhfOrder.Contains("voyage") ? wwi_func.vint(this.dxhfOrder.Get("voyage").ToString()) : 0;
        int _vesselid = this.dxhfOrder.Contains("vessel") ? wwi_func.vint(this.dxhfOrder.Get("vessel").ToString()) : 0; 
        //key for this record
        int _etsid = e.Keys["VoyageETSSubID"] != null ? wwi_func.vint(e.Keys["VoyageETSSubID"].ToString()) : 0;
        //other required data
        int _portid =  e.NewValues["OriginPortID"] != null ? wwi_func.vint(e.NewValues["OriginPortID"].ToString()) : 0;
        DateTime? _dtets = e.NewValues["ETS"] != null ? wwi_func.vdatetime(e.NewValues["ETS"].ToString()) : (DateTime?)null; 
        
        ASPxComboBox _cbo = (ASPxComboBox)this.fmvVoyage.FindControl("dxcboVesselID");
        if (_cbo != null && _cbo.Value != null)
        {
            _vesselid = wwi_func.vint(_cbo.Value.ToString());
        }

        if (_etsid > 0)
        {
            VoyageETSSubTable _tbl = new VoyageETSSubTable(_etsid);
            _tbl.OriginPortID = _portid;
            _tbl.Ets = _dtets;
            _tbl.Save();

            //***** for testing
            //_portid = 1;
            //_vesselid = 3246;
            //*****

            //update ordertable if _portid > 0 and _vesselid > 0 
            //use voayge id NOT vessel id
            //if (_portid > 0 && _vesselid > 0) //&& (e.NewValues["ETS"] != e.OldValues["ETS"]))
            if (_portid > 0 && _voyageid > 0)
            {
                //update_ordertable_ets(_portid, _vesselid, _dtets);
                update_ordertable_ets(_portid, _voyageid, _dtets);

                //also does not work!
                //string[] _cols = { "OrderID", "ETS", "VesselLastUpdated" };
                //SqlQuery _qry = new Select(_cols).From(DAL.Logistics.Tables.OrderTable).
                //    Where(OrderTable.PortIDColumn).IsEqualTo(_portid).And(OrderTable.VesselIDColumn).IsEqualTo(_vesselid);
                //DataTable _dt = new DataTable();
                //DataColumn[] _col = { _dt.Columns["OrderID"] }; //need to define a primary key for update to work
                //_dt.PrimaryKey = _col;
                //
                //SqlDataAdapter _da = new SqlDataAdapter();
                //SqlCommandBuilder _cb = new SqlCommandBuilder(_da); 
                //ConnectionStringSettings _cs = ConfigurationManager.ConnectionStrings["PublishipSQLConnectionString"];
                //using (SqlConnection _con = new SqlConnection(_cs.ConnectionString))
                //using (SqlCommand _cmd = new SqlCommand())
                //{
                    //_cmd.CommandText = "SELECT OrderID, ETS, VesselLastUpdated FROM OrderTable WHERE ((PortID=@idport) AND (VesselID=@idvessel));";
                    //_cmd.Parameters.AddWithValue("@idport", _portid);
                    //_cmd.Parameters.AddWithValue("@idvessel", _vesselid);
                    //_cmd.Connection = _con;
                    //_da.SelectCommand = _cmd; 
                    //_da.Fill(_dt);
                                       
                    //for (int _ix = 0; _ix < _dt.Rows.Count; _ix++)
                    //{
                    //    _dt.Rows[_ix]["ETS"] = Convert.ToDateTime(_dtets);
                    //    _dt.Rows[_ix]["VesselLastUpdated"] = Convert.ToDateTime(_now);
                    //}
                    //
                    //int _result = _da.Update(_dt); 
                //}
                
                //does not work
                //string _sql = "UPDATE OrderTable " +
                //                    "SET OrderTable.Ets=@etsdate, " +
                //                    "OrderTable.VesselLastUpdated=@now " +
                //                    "FROM OrderTable as o " +
                //                    "WHERE o.OrderID IN (SELECT DISTINCT OrderID FROM OrderTable WHERE ((o.PortID=@port) AND (o.VesselID=@vessel)));";
                //ConnectionStringSettings _cs = ConfigurationManager.ConnectionStrings["PublishipSQLConnectionString"];
                //using (SqlConnection _con = new SqlConnection(_cs.ConnectionString))
                //using (SqlCommand _cmd = new SqlCommand())
                //{
                //    _cmd.CommandText = _sql;
                //    _cmd.Parameters.AddWithValue("@etsdate", Convert.ToDateTime(_dtets));
                //   _cmd.Parameters.AddWithValue("@now", Convert.ToDateTime(_now));
                //   _cmd.Parameters.AddWithValue("@port", _portid);
                //    _cmd.Parameters.AddWithValue("@vessel", _vesselid);
                //   _cmd.Connection = _con;
                //    _con.Open();
                //    int _result = _cmd.ExecuteNonQuery();
                //}
                
                //does not work
                //string[] _cols = { "OrderID" };
                //SqlQuery _qry = new Select(_cols).From(DAL.Logistics.Tables.OrderTable).
                //    Where(OrderTable.PortIDColumn).IsEqualTo(_portid).And(OrderTable.VesselIDColumn).IsEqualTo(_vesselid);
                //
                //IList<int> _orders = _qry.ExecuteTypedList<int>();
                //if (_orders.Count > 0)
                //{ 
                //    SubSonic.Update _upd = new SubSonic.Update(DAL.Logistics.Schemas.OrderTable);
                //    IList<int> _recordsaffected = _upd.Set(OrderTable.EtsColumn).EqualTo(Convert.ToDateTime(_dtets)).
                //                            Set(OrderTable.VesselLastUpdatedColumn).EqualTo(Convert.ToDateTime(_now)).
                //                            Where(OrderTable.OrderIDColumn).In(_orders).ExecuteTypedList<int>();        
                //}
            }
            //end if vesselid > 0
        }//end if voyageetssubid > 0

        //MUST call this after insert or error: Specified method is not supported
        e.Cancel = true;
        _grd.CancelEdit();
        //rebind
        bind_ets_grid(_voyageid);  
    }
Example #8
0
    /// <summary>
    /// insert event for ETS grid
    /// save to VoyageETSSubTable
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dxgrdETS_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxGridView _grd = (ASPxGridView)sender; 
        DateTime? _dtnull = null;
        
        int _voyageid = this.dxhfOrder.Contains("voyage") ? wwi_func.vint( this.dxhfOrder.Get("voyage").ToString() ): 0;
        int _vesselid = this.dxhfOrder.Contains("vessel") ? wwi_func.vint(this.dxhfOrder.Get("vessel").ToString()) : 0; 
        int _portid = e.NewValues["OriginPortID"] != null ? wwi_func.vint(e.NewValues["OriginPortID"].ToString()) : 0;
        DateTime? _dtets = e.NewValues["ETS"] != null ? wwi_func.vdatetime(e.NewValues["ETS"].ToString()): _dtnull;

        if (_voyageid > 0)
        {
            VoyageETSSubTable _tbl = new VoyageETSSubTable();
            _tbl.VoyageID = _voyageid;
            _tbl.OriginPortID = _portid;
            _tbl.Ets = _dtets;
            _tbl.Save();

            if (_portid > 0 && _vesselid > 0)
            {
                update_ordertable_ets(_portid, _vesselid, _dtets);
            }
        }
        //MUST call this after insert or error: Specified method is not supported
        e.Cancel = true;
        _grd.CancelEdit(); 
        //rebind
        bind_ets_grid(_voyageid);  
        
    }
 public bool Destroy(object VoyageETSSubID)
 {
     return(VoyageETSSubTable.Destroy(VoyageETSSubID) == 1);
 }
 public bool Delete(object VoyageETSSubID)
 {
     return(VoyageETSSubTable.Delete(VoyageETSSubID) == 1);
 }
Example #11
0
    /// <summary>
    /// update event for ETS grid
    /// check DATE. if it's been changed will need to update order table
    /// ordertable.ETS = new ETS, ordertable.VesselLastUpdated = now where ordertable.PortID = OriginPortID and ordertable.VesselID = VesselID
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dxgrdETS_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView _grd = (ASPxGridView)sender;

        int _voyageid = this.dxhfOrder.Contains("voyage") ? wwi_func.vint(this.dxhfOrder.Get("voyage").ToString()) : 0;
        int _vesselid = this.dxhfOrder.Contains("vessel") ? wwi_func.vint(this.dxhfOrder.Get("vessel").ToString()) : 0;
        //key for this record
        int _etsid = e.Keys["VoyageETSSubID"] != null?wwi_func.vint(e.Keys["VoyageETSSubID"].ToString()) : 0;

        //other required data
        int _portid = e.NewValues["OriginPortID"] != null?wwi_func.vint(e.NewValues["OriginPortID"].ToString()) : 0;

        DateTime?_dtets = e.NewValues["ETS"] != null?wwi_func.vdatetime(e.NewValues["ETS"].ToString()) : (DateTime?)null;

        ASPxComboBox _cbo = (ASPxComboBox)this.fmvVoyage.FindControl("dxcboVesselID");

        if (_cbo != null && _cbo.Value != null)
        {
            _vesselid = wwi_func.vint(_cbo.Value.ToString());
        }

        if (_etsid > 0)
        {
            VoyageETSSubTable _tbl = new VoyageETSSubTable(_etsid);
            _tbl.OriginPortID = _portid;
            _tbl.Ets          = _dtets;
            _tbl.Save();

            //***** for testing
            //_portid = 1;
            //_vesselid = 3246;
            //*****

            //update ordertable if _portid > 0 and _vesselid > 0
            //use voayge id NOT vessel id
            //if (_portid > 0 && _vesselid > 0) //&& (e.NewValues["ETS"] != e.OldValues["ETS"]))
            if (_portid > 0 && _voyageid > 0)
            {
                //update_ordertable_ets(_portid, _vesselid, _dtets);
                update_ordertable_ets(_portid, _voyageid, _dtets);

                //also does not work!
                //string[] _cols = { "OrderID", "ETS", "VesselLastUpdated" };
                //SqlQuery _qry = new Select(_cols).From(DAL.Logistics.Tables.OrderTable).
                //    Where(OrderTable.PortIDColumn).IsEqualTo(_portid).And(OrderTable.VesselIDColumn).IsEqualTo(_vesselid);
                //DataTable _dt = new DataTable();
                //DataColumn[] _col = { _dt.Columns["OrderID"] }; //need to define a primary key for update to work
                //_dt.PrimaryKey = _col;
                //
                //SqlDataAdapter _da = new SqlDataAdapter();
                //SqlCommandBuilder _cb = new SqlCommandBuilder(_da);
                //ConnectionStringSettings _cs = ConfigurationManager.ConnectionStrings["PublishipSQLConnectionString"];
                //using (SqlConnection _con = new SqlConnection(_cs.ConnectionString))
                //using (SqlCommand _cmd = new SqlCommand())
                //{
                //_cmd.CommandText = "SELECT OrderID, ETS, VesselLastUpdated FROM OrderTable WHERE ((PortID=@idport) AND (VesselID=@idvessel));";
                //_cmd.Parameters.AddWithValue("@idport", _portid);
                //_cmd.Parameters.AddWithValue("@idvessel", _vesselid);
                //_cmd.Connection = _con;
                //_da.SelectCommand = _cmd;
                //_da.Fill(_dt);

                //for (int _ix = 0; _ix < _dt.Rows.Count; _ix++)
                //{
                //    _dt.Rows[_ix]["ETS"] = Convert.ToDateTime(_dtets);
                //    _dt.Rows[_ix]["VesselLastUpdated"] = Convert.ToDateTime(_now);
                //}
                //
                //int _result = _da.Update(_dt);
                //}

                //does not work
                //string _sql = "UPDATE OrderTable " +
                //                    "SET OrderTable.Ets=@etsdate, " +
                //                    "OrderTable.VesselLastUpdated=@now " +
                //                    "FROM OrderTable as o " +
                //                    "WHERE o.OrderID IN (SELECT DISTINCT OrderID FROM OrderTable WHERE ((o.PortID=@port) AND (o.VesselID=@vessel)));";
                //ConnectionStringSettings _cs = ConfigurationManager.ConnectionStrings["PublishipSQLConnectionString"];
                //using (SqlConnection _con = new SqlConnection(_cs.ConnectionString))
                //using (SqlCommand _cmd = new SqlCommand())
                //{
                //    _cmd.CommandText = _sql;
                //    _cmd.Parameters.AddWithValue("@etsdate", Convert.ToDateTime(_dtets));
                //   _cmd.Parameters.AddWithValue("@now", Convert.ToDateTime(_now));
                //   _cmd.Parameters.AddWithValue("@port", _portid);
                //    _cmd.Parameters.AddWithValue("@vessel", _vesselid);
                //   _cmd.Connection = _con;
                //    _con.Open();
                //    int _result = _cmd.ExecuteNonQuery();
                //}

                //does not work
                //string[] _cols = { "OrderID" };
                //SqlQuery _qry = new Select(_cols).From(DAL.Logistics.Tables.OrderTable).
                //    Where(OrderTable.PortIDColumn).IsEqualTo(_portid).And(OrderTable.VesselIDColumn).IsEqualTo(_vesselid);
                //
                //IList<int> _orders = _qry.ExecuteTypedList<int>();
                //if (_orders.Count > 0)
                //{
                //    SubSonic.Update _upd = new SubSonic.Update(DAL.Logistics.Schemas.OrderTable);
                //    IList<int> _recordsaffected = _upd.Set(OrderTable.EtsColumn).EqualTo(Convert.ToDateTime(_dtets)).
                //                            Set(OrderTable.VesselLastUpdatedColumn).EqualTo(Convert.ToDateTime(_now)).
                //                            Where(OrderTable.OrderIDColumn).In(_orders).ExecuteTypedList<int>();
                //}
            }
            //end if vesselid > 0
        }//end if voyageetssubid > 0

        //MUST call this after insert or error: Specified method is not supported
        e.Cancel = true;
        _grd.CancelEdit();
        //rebind
        bind_ets_grid(_voyageid);
    }