public List <ProductionSetWeekDetail> LoadProductionSetWeekDetailByID(ProductionSetWeekDetail obj)
        {
            string sql = @"Select 
                              [ID]
                             ,[SetID]
                             ,[WeekNo]
                             ,[MaxCapacity]
                             ,[TotalAreal]
                       From [BE_ProductionSetWeekDetail] With(NoLock) Where ID=@ID";

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

            SqlParameter pID = new SqlParameter("ID", Convert2DBnull(obj.ID));

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

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

            try
            {
                while (dr.Read())
                {
                    ProductionSetWeekDetail iret = new ProductionSetWeekDetail();
                    if (!Convert.IsDBNull(dr["ID"]))
                    {
                        iret.ID = (Guid)dr["ID"];
                    }
                    if (!Convert.IsDBNull(dr["SetID"]))
                    {
                        iret.SetID = (Guid)dr["SetID"];
                    }
                    if (!Convert.IsDBNull(dr["WeekNo"]))
                    {
                        iret.WeekNo = (int)dr["WeekNo"];
                    }
                    if (!Convert.IsDBNull(dr["MaxCapacity"]))
                    {
                        iret.MaxCapacity = (decimal)dr["MaxCapacity"];
                    }
                    if (!Convert.IsDBNull(dr["TotalAreal"]))
                    {
                        iret.TotalAreal = (decimal)dr["TotalAreal"];
                    }
                    ret.Add(iret);
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }
        public List <ProductionSetWeekDetail> LoadProductionSetWeekDetails()
        {
            string sql = @"Select 
                              [ID]
                             ,[SetID]
                             ,[WeekNo]
                             ,[MaxCapacity]
                             ,[TotalAreal]
                       From [BE_ProductionSetWeekDetail] With(NoLock)";

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

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

            try
            {
                while (dr.Read())
                {
                    ProductionSetWeekDetail iret = new ProductionSetWeekDetail();
                    if (!Convert.IsDBNull(dr["ID"]))
                    {
                        iret.ID = (Guid)dr["ID"];
                    }
                    if (!Convert.IsDBNull(dr["SetID"]))
                    {
                        iret.SetID = (Guid)dr["SetID"];
                    }
                    if (!Convert.IsDBNull(dr["WeekNo"]))
                    {
                        iret.WeekNo = (int)dr["WeekNo"];
                    }
                    if (!Convert.IsDBNull(dr["MaxCapacity"]))
                    {
                        iret.MaxCapacity = (decimal)dr["MaxCapacity"];
                    }
                    if (!Convert.IsDBNull(dr["TotalAreal"]))
                    {
                        iret.TotalAreal = (decimal)dr["TotalAreal"];
                    }
                    ret.Add(iret);
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }
        public int InsertProductionSetWeekDetail(ProductionSetWeekDetail obj)
        {
            string sql = @"Insert Into [BE_ProductionSetWeekDetail](
                              [ID]
                             ,[SetID]
                             ,[WeekNo]
                             ,[MaxCapacity]
                             ,[TotalAreal]
            )Values (
                              @ID
                             ,@SetID
                             ,@WeekNo
                             ,@MaxCapacity
                             ,@TotalAreal
                    )";

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

            SqlParameter pID = new SqlParameter("ID", Convert2DBnull(obj.ID));

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

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

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

            SqlParameter pWeekNo = new SqlParameter("WeekNo", Convert2DBnull(obj.WeekNo));

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

            SqlParameter pMaxCapacity = new SqlParameter("MaxCapacity", Convert2DBnull(obj.MaxCapacity));

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

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

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

            return(cmd.ExecuteNonQuery());
        }
        public int UpdateProductionSetWeekDetailByID(ProductionSetWeekDetail obj)
        {
            string sql = @"Update [BE_ProductionSetWeekDetail] Set
                              [SetID]=@SetID
                             ,[WeekNo]=@WeekNo
                             ,[MaxCapacity]=@MaxCapacity
                             ,[TotalAreal]=@TotalAreal
                          Where ID=@ID";

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

            SqlParameter pID = new SqlParameter("ID", Convert2DBnull(obj.ID));

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

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

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

            SqlParameter pWeekNo = new SqlParameter("WeekNo", Convert2DBnull(obj.WeekNo));

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

            SqlParameter pMaxCapacity = new SqlParameter("MaxCapacity", Convert2DBnull(obj.MaxCapacity));

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

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

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

            return(cmd.ExecuteNonQuery());
        }