コード例 #1
0
        public static ServiceWorkList GetListByDate(DateTime theDate, string startTime)
        {
            ServiceWorkList aList  = null;
            MyDBConnection  myConn = new MyDBConnection();
            SqlConnection   conn   = new SqlConnection();
            SqlDataReader   dr;
            SqlCommand      cmd = null;
            //string sql = "Select * from AquaOne.dbo.ServiceWork where serviceDate = @ServiceDate and serviceStartTime > @ServiceStartTime ";
            string sql = "Select * from AquaOne.dbo.ServiceWork where serviceDate = @ServiceDate and serviceStartTime > @ServiceStartTime order by serviceStartTime";

            try
            {
                // Open the connection
                conn = myConn.OpenDB();
                cmd  = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@ServiceDate", SqlDbType.DateTime).Value = theDate.Date;
                DateTime serviceStartTime = Convert.ToDateTime(startTime);
                cmd.Parameters.Add("@ServiceStartTime", SqlDbType.Time).Value = new TimeSpan(serviceStartTime.Hour, serviceStartTime.Minute, 0);

                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                if (dr.HasRows)
                {
                    aList = new ServiceWorkList();
                    while (dr.Read())
                    {
                        aList.Add(FillDataRecord(dr));
                    }
                }

                cmd.Dispose();
                dr.Close();
            }
            finally
            {
                myConn.CloseDB(conn);
            }

            return(aList);
        }
コード例 #2
0
        public static ServiceWorkList GetListByAccountID(int accountID)
        {
            ServiceWorkList aList  = null;
            MyDBConnection  myConn = new MyDBConnection();
            SqlConnection   conn   = new SqlConnection();
            SqlDataReader   dr;
            SqlCommand      cmd = null;
            string          sql = "Select * from AquaOne.dbo.ServiceWork where accountID = @accountID";

            try
            {
                // Open the connection
                conn = myConn.OpenDB();
                cmd  = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@accountID", SqlDbType.Int).Value = accountID;

                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                if (dr.HasRows)
                {
                    aList = new  ServiceWorkList();
                    while (dr.Read())
                    {
                        aList.Add(FillDataRecord(dr));
                    }
                }

                cmd.Dispose();
                dr.Close();
            }
            finally
            {
                myConn.CloseDB(conn);
            }

            return(aList);
        }