Ejemplo n.º 1
0
 public static List<Customer> Select()
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         return entities.Customers.ToList();
     }
     catch (Exception)
     {
         return null;
     }
 }
Ejemplo n.º 2
0
 public static Customer Select(Int64 id)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         return entities.Customers.FirstOrDefault(ob => ob.Id == id);
     }
     catch (Exception)
     {
         return null;
     }
 }
Ejemplo n.º 3
0
 public static List<Customer> SearchCustomerByText(string txtInput)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         return entities.Customers.Where(ob => ob.FullName.Contains(txtInput)).ToList();
     }
     catch (Exception)
     {
         return null;
     }
 }
Ejemplo n.º 4
0
 public static bool Insert(Customer customer)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         entities.Customers.Add(customer);
         entities.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Insert Ticket
 /// </summary>
 /// <param name="tk"></param>
 /// <returns></returns>
 public static bool Insert(Ticket tk)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         entities.Tickets.Add(tk);
         entities.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Ejemplo n.º 6
0
 public static Int64 SelectIdbyName(string name)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         var query = from cs in entities.Customers
                     where name.ToLower().Trim() == cs.FullName.ToLower().Trim()
                     select cs.Id;
         return query.First();
     }
     catch (Exception)
     {
         return 0;
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Delete Ticket
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public static bool Delete(Int64 id)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         var ticket = entities.Tickets.First(ob => ob.TicketId == id);
         entities.Entry(ticket).State = EntityState.Deleted;
         entities.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchText"></param>
 /// <returns></returns>
 public static IQueryable<String> Suggestion(string searchText)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         var query = from pl in entities.Motorbikes
                     select pl.Plate;
         var namelist = query.Where(n => n.ToLower().StartsWith(searchText.ToLower()));
         return namelist;
     }
     catch (Exception)
     {
         return null;
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="plate"></param>
 /// <returns></returns>
 public static MotorType SelectMotorTypeByPlate(String plate)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         var query = from tiket in entities.Tickets
                     where tiket.MotorbikePlate == plate
                     join motor in entities.Motorbikes on tiket.MotorbikePlate equals motor.Plate
                     join motorType in entities.MotorTypes on motor.MotorType equals motorType.Id
                     select motorType;
         return query.First();
     }
     catch (Exception)
     {
         return null;
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Search by custom search query
        /// </summary>
        /// <param name="sContent"></param>
        /// <returns></returns>
        public static List<Ticket> Search(String sContent)
        {
            // Make input valid
            sContent = (sContent + String.Empty).ToLower();

            try
            {
                QLNXeEntities entities = new QLNXeEntities();
                var query = from tk in entities.Tickets
                            join cus in entities.Customers
                            on tk.CustomerId equals cus.Id
                            where (tk.MotorbikePlate + String.Empty).ToLower().Contains(sContent)
                                || (cus.FullName + String.Empty).ToLower().Contains(sContent)
                            select tk;

                return query.Take(1000).ToList();
            }
            catch
            {
                return new List<Ticket>();
            }
        }
Ejemplo n.º 11
0
 public static bool Update(Customer customer)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         var customers = entities.Customers.Find(customer.Id);
         entities.Entry(customers).CurrentValues.SetValues(customer);
         entities.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Ejemplo n.º 12
0
 public static IQueryable<String> Suggestion(string searchText)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         var query = from cs in entities.Customers
                     select cs.FullName;
         var namelist = query.Where(n => n.ToLower().StartsWith(searchText.ToLower()));
         return namelist;
     }
     catch (Exception)
     {
         return null;
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Select All Ticket
 /// </summary>
 /// <returns></returns>
 public static List<Ticket> Select()
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         return entities.Tickets.ToList();
     }
     catch (Exception)
     {
         return null;
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Update Ticket
 /// </summary>
 /// <param name="tk"></param>
 /// <returns></returns>
 public static bool Update(Ticket tk)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         var ticket = entities.Tickets.Find(tk.TicketId);
         entities.Entry(ticket).CurrentValues.SetValues(tk);
         entities.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Select ticket type by plate
        /// </summary>
        /// <param name="plate"></param>
        /// <returns></returns>
        public static TicketType SelectTypeByPlate(String plate)
        {
            try
            {
                QLNXeEntities entities = new QLNXeEntities();
                var query = from tk in entities.Tickets
                            where tk.MotorbikePlate == plate
                            join tkType in entities.TicketTypes
                            on tk.TypeId equals tkType.Id
                            select tkType;

                return query.First();
            }
            catch
            {
                return null;
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Select Ticket by Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public static Ticket Select(Int64 id)
 {
     try
     {
         QLNXeEntities entities = new QLNXeEntities();
         return entities.Tickets.FirstOrDefault(ob => ob.TicketId == id);
     }
     catch (Exception)
     {
         return null;
     }
 }