示例#1
0
        public ActivityMachineCollec Get(Activity objActivity)
        {
            ActivityMachineCollec objActivityMachineCollec = new ActivityMachineCollec();
            Activity_DL           objActivityDL            = new Activity_DL(Connection);
            Machine_DL            objMachineDL             = new Machine_DL(Connection);

            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@ActID", objActivity.ActivityID)
                };

                DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_ActivityMachine_By_ActID", paramList);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ActivityMachine obj = new ActivityMachine();

                    if (dt.Rows[i]["ActID"] != null)
                    {
                        obj.Activity = objActivityDL.Get(Convert.ToInt64(dt.Rows[i]["ActID"]));
                    }

                    if (dt.Rows[i]["MachineID"] != null)
                    {
                        obj.Machine = objMachineDL.Get(Convert.ToString(dt.Rows[i]["MachineID"]));
                    }

                    obj.EstimatedHour = Convert.ToDecimal(dt.Rows[i]["EstimatedHours"]);

                    objActivityMachineCollec.Add(obj);
                }

                return(objActivityMachineCollec);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }