Exemple #1
0
 public static bool DriverTruckIsUnique(truck c)
 {
     try
     {
         int count;
         var s = TruckSystemRepo.GetInstance().ExecuteScalar <string>("SELECT COUNT(id) FROM trucks WHERE driver_id=@0", c.driver_id);
         if (s.Equals(DBNull.Value) || String.IsNullOrEmpty(s))
         {
             count = 0;
         }
         else
         {
             count = Convert.ToInt32(s);
         }
         if (count == 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex.InnerException);
     }
 }
Exemple #2
0
 internal static bool NumberRntrcUnique(antts an)
 {
     try
     {
         int count;
         var s = TruckSystemRepo.GetInstance().ExecuteScalar <string>
                     ("SELECT COUNT(id) FROM antts WHERE rntrc=@0", an.rntrc);
         if (s.Equals(DBNull.Value) || String.IsNullOrEmpty(s))
         {
             count = 0;
         }
         else
         {
             count = Convert.ToInt32(s);
         }
         if (count == 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex.InnerException);
     }
 }
Exemple #3
0
            public static bool DocumentCustomerIsUnique(customer c)
            {
                try
                {
                    string s = TruckSystemRepo.GetInstance().ExecuteScalar <string>
                                   ("SELECT COUNT(id) FROM customers WHERE document=@0", c.document);
                    int count;
                    if (s.Equals(DBNull.Value) || String.IsNullOrEmpty(s))
                    {
                        count = 0;
                    }
                    else
                    {
                        count = Convert.ToInt32(s);
                    }

                    if (count == 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message, ex.InnerException);
                }
            }
 decimal totalStays(long freight_id)
 {
     try
     {
         var result = TruckSystemRepo.GetInstance().ExecuteScalar <string>("SELECT SUM(total) FROM stays WHERE freight_id=@0",
                                                                           freight_id);
         if (result.Equals(DBNull.Value) || String.IsNullOrEmpty(result))
         {
             return(0);
         }
         else
         {
             return(Convert.ToDecimal(result));
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(String.Format("Ocorreu um erro:\n\n{0}\n{1}", ex.Message, ex.InnerException));
     }
     return(0);
 }