Example #1
0
        public int UpdateProductionSetBySetID(ProductionSet obj)
        {
            string sql = @"Update [BE_ProductionSet] Set
                              [Started]=@Started
                             ,[Ended]=@Ended
                             ,[Weeks]=@Weeks
                             ,[Days]=@Days
                             ,[TotalAreal]=@TotalAreal
                             ,[Created]=@Created
                             ,[CreatedBy]=@CreatedBy
                          Where SetID=@SetID";

            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pSetID = new SqlParameter("SetID", Convert2DBnull(obj.SetID));

            pSetID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pSetID);

            SqlParameter pStarted = new SqlParameter("Started", Convert2DBnull(obj.Started));

            pStarted.SqlDbType = SqlDbType.SmallDateTime;
            cmd.Parameters.Add(pStarted);

            SqlParameter pEnded = new SqlParameter("Ended", Convert2DBnull(obj.Ended));

            pEnded.SqlDbType = SqlDbType.SmallDateTime;
            cmd.Parameters.Add(pEnded);

            SqlParameter pWeeks = new SqlParameter("Weeks", Convert2DBnull(obj.Weeks));

            pWeeks.SqlDbType = SqlDbType.Int;
            cmd.Parameters.Add(pWeeks);

            SqlParameter pDays = new SqlParameter("Days", Convert2DBnull(obj.Days));

            pDays.SqlDbType = SqlDbType.Int;
            cmd.Parameters.Add(pDays);

            SqlParameter pTotalAreal = new SqlParameter("TotalAreal", Convert2DBnull(obj.TotalAreal));

            pTotalAreal.SqlDbType = SqlDbType.Decimal;
            cmd.Parameters.Add(pTotalAreal);

            SqlParameter pCreated = new SqlParameter("Created", Convert2DBnull(obj.Created));

            pCreated.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pCreated);

            SqlParameter pCreatedBy = new SqlParameter("CreatedBy", Convert2DBnull(obj.CreatedBy));

            pCreatedBy.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pCreatedBy);

            return(cmd.ExecuteNonQuery());
        }
Example #2
0
        public int LoadProductionSet(ProductionSet obj)
        {
            string sql = @"Select 
                              [SetID]
                             ,[Started]
                             ,[Ended]
                             ,[Weeks]
                             ,[Days]
                             ,[TotalAreal]
                             ,[Created]
                             ,[CreatedBy]
                       From [BE_ProductionSet] With(NoLock) Where SetID=@SetID";

            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pSetID = new SqlParameter("SetID", Convert2DBnull(obj.SetID));

            pSetID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pSetID);

            int           ret = 0;
            SqlDataReader dr  = cmd.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    if (!Convert.IsDBNull(dr["SetID"]))
                    {
                        obj.SetID = (Guid)dr["SetID"];
                    }
                    if (!Convert.IsDBNull(dr["Started"]))
                    {
                        obj.Started = (DateTime)dr["Started"];
                    }
                    if (!Convert.IsDBNull(dr["Ended"]))
                    {
                        obj.Ended = (DateTime)dr["Ended"];
                    }
                    if (!Convert.IsDBNull(dr["Weeks"]))
                    {
                        obj.Weeks = (int)dr["Weeks"];
                    }
                    if (!Convert.IsDBNull(dr["Days"]))
                    {
                        obj.Days = (int)dr["Days"];
                    }
                    if (!Convert.IsDBNull(dr["TotalAreal"]))
                    {
                        obj.TotalAreal = (decimal)dr["TotalAreal"];
                    }
                    if (!Convert.IsDBNull(dr["Created"]))
                    {
                        obj.Created = (DateTime)dr["Created"];
                    }
                    if (!Convert.IsDBNull(dr["CreatedBy"]))
                    {
                        obj.CreatedBy = (string)dr["CreatedBy"];
                    }
                    ret += 1;
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }
Example #3
0
        public List <ProductionSet> LoadProductionSets()
        {
            string sql = @"Select 
                              [SetID]
                             ,[Started]
                             ,[Ended]
                             ,[Weeks]
                             ,[Days]
                             ,[TotalAreal]
                             ,[Created]
                             ,[CreatedBy]
                       From [BE_ProductionSet] With(NoLock)";

            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            List <ProductionSet> ret = new List <ProductionSet>();
            SqlDataReader        dr  = cmd.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    ProductionSet iret = new ProductionSet();
                    if (!Convert.IsDBNull(dr["SetID"]))
                    {
                        iret.SetID = (Guid)dr["SetID"];
                    }
                    if (!Convert.IsDBNull(dr["Started"]))
                    {
                        iret.Started = (DateTime)dr["Started"];
                    }
                    if (!Convert.IsDBNull(dr["Ended"]))
                    {
                        iret.Ended = (DateTime)dr["Ended"];
                    }
                    if (!Convert.IsDBNull(dr["Weeks"]))
                    {
                        iret.Weeks = (int)dr["Weeks"];
                    }
                    if (!Convert.IsDBNull(dr["Days"]))
                    {
                        iret.Days = (int)dr["Days"];
                    }
                    if (!Convert.IsDBNull(dr["TotalAreal"]))
                    {
                        iret.TotalAreal = (decimal)dr["TotalAreal"];
                    }
                    if (!Convert.IsDBNull(dr["Created"]))
                    {
                        iret.Created = (DateTime)dr["Created"];
                    }
                    if (!Convert.IsDBNull(dr["CreatedBy"]))
                    {
                        iret.CreatedBy = (string)dr["CreatedBy"];
                    }
                    ret.Add(iret);
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }