Esempio n. 1
0
        public static STG_ServiceWorkList GetListByDate(DateTime theDate, string startTime)
        {
            STG_ServiceWorkList aList  = null;
            MyDBConnection      myConn = new MyDBConnection();
            SqlConnection       conn   = new SqlConnection();
            SqlDataReader       dr;
            SqlCommand          cmd = null;
            string sql = "Select * from AquaOne.dbo.STG_ServiceWork where serviceDate = @ServiceDate and serviceStartTime > @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 STG_ServiceWorkList();
                    while (dr.Read())
                    {
                        aList.Add(FillDataRecord(dr));
                    }
                }

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

            return(aList);
        }
Esempio n. 2
0
        public static STG_ServiceWorkList GetListByAccountID(int accountID)
        {
            STG_ServiceWorkList aList  = null;
            MyDBConnection      myConn = new MyDBConnection();
            SqlConnection       conn   = new SqlConnection();
            SqlDataReader       dr;
            SqlCommand          cmd = null;
            string sql = "Select * from AquaOne.dbo.STG_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 STG_ServiceWorkList();
                    while (dr.Read())
                    {
                        aList.Add(FillDataRecord(dr));
                    }
                }

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

            return(aList);
        }