Esempio n. 1
0
        private void DataPortal_Fetch(WateringSession.Criteria criteria)
        {
            TransactionHandler.ProcessTransaction((tr) =>
            {
                using (var cm = tr.CreateCommand())
                {
                    this.RaiseListChangedEvents = false;

                    cm.CommandText = "usp_WateringSession";
                    cm.CommandType = CommandType.StoredProcedure;

                    cm.Parameters.AddWithValue("@action", criteria.Action);
                    cm.Parameters.AddWithValue("@Id", criteria.Id);

                    if (criteria.Action == "getbytapmangoplantid")
                    {
                        cm.Parameters.AddWithValue("@TapMangoPlantId", criteria.TapMangoPlantId);
                    }

                    using (var dr = new SafeDataReader(cm.ExecuteReader()))
                    {
                        while (dr.Read())
                        {
                            this.Add(new WateringSession(dr));
                        }
                    }

                    this.RaiseListChangedEvents = true;
                }
            });
        }
Esempio n. 2
0
        public static WateringSessionList GetByTapMangoPlantId(int tapMangoPlantId)
        {
            var criteria = new WateringSession.Criteria()
            {
                Action = "getbytapmangoplantid", TapMangoPlantId = tapMangoPlantId
            };

            return(DataPortal.Fetch <WateringSessionList>(criteria));
        }
Esempio n. 3
0
        private void DataPortal_Delete(WateringSession.Criteria criteria)
        {
            TransactionHandler.ProcessTransaction((tr) =>
            {
                using (var cm = tr.CreateCommand())
                {
                    cm.CommandText = "usp_WateringSession";
                    cm.CommandType = CommandType.StoredProcedure;

                    cm.Parameters.AddWithValue("@action", "delete");
                    cm.Parameters.AddWithValue("@Id", criteria.Id);

                    cm.ExecuteNonQuery();

                    this.MarkNew();
                }
            });
        }
Esempio n. 4
0
        private void DataPortal_Fetch(WateringSession.Criteria criteria)
        {
            TransactionHandler.ProcessTransaction((tr) =>
            {
                using (var cm = tr.CreateCommand())
                {
                    cm.CommandText = "usp_WateringSession";
                    cm.CommandType = CommandType.StoredProcedure;

                    cm.Parameters.AddWithValue("@action", criteria.Action);
                    cm.Parameters.AddWithValue("@Id", criteria.Id);

                    using (var dr = new SafeDataReader(cm.ExecuteReader()))
                    {
                        if (dr.Read())
                        {
                            FillSelf(dr);
                        }
                    }
                }
            });
        }