コード例 #1
0
 public bool Update(DateTime pDate,
                    uint pBusCode,
                    string pDriverCode,
                    int pOwnerCode,
                    uint pLineCode,
                    int pZoneCode,
                    uint pPrice)
 {
     ClassLibrary.JDataBase DB = new ClassLibrary.JDataBase();
     try
     {
         DB.setQuery(@"SELECT Code FROM AUTDailyPerformanceRportOnBus
                     WHERE 
                     CAST(Date as date)=CAST('" + pDate.ToString("yyyy-MM-dd") + @"' as date) AND
                     BusCode=@BusCode AND
                     DriverCode=@DriverCode AND
                     OwnerCode=@OwnerCode AND
                     LineCode=@LineCode AND
                     ZoneCode=@ZoneCode AND 
                     DocumentCode <> 0 AND DocumentCode IS NOT Null ");
         DB.AddParams("Date", pDate);
         DB.AddParams("BusCode", Convert.ToInt32(pBusCode));
         DB.AddParams("DriverCode", pDriverCode);
         DB.AddParams("OwnerCode", pOwnerCode);
         DB.AddParams("LineCode", Convert.ToInt32(pLineCode));
         DB.AddParams("ZoneCode", pZoneCode);
         DB.AddParams("Price", Convert.ToInt32(pPrice));
         System.Data.DataTable DT = DB.Query_DataTable();
         if (DT.Rows.Count > 1)
         {
         }
         else
         if (DT.Rows.Count == 1)
         {
             DB.setQuery(@"UPDATE AUTDailyPerformanceRportOnBus SET Price=Price+@Price , TCount=TCount+1
                             WHERE Code = " + DT.Rows[0][0].ToString());
             if (DB.Query_Execute() >= 0)
             {
                 return(true);
             }
             return(false);
         }
         else
         {
             DB.setQuery(@"INSERT INTO AUTDailyPerformanceRportOnBus 
                                 (Code,Date,BusCode,DriverCode,OwnerCode,LineCode,ZoneCode,Price,TCount)
                                 Values(
                                 isnull((Select MAX(Code) From AUTDailyPerformanceRportOnBus), 0) + 1,
                                 @Date,
                                 @BusCode,
                                 @DriverCode,
                                 @OwnerCode,
                                 @LineCode,
                                 @ZoneCode,
                                 @Price,
                                 1
                                 )");
             if (DB.Query_Execute() >= 0)
             {
                 return(true);
             }
             return(false);
         }
     }
     finally
     {
         DB.Dispose();
     }
     return(false);
 }