Ejemplo n.º 1
0
 public bool Delete(ClientInformation c)
 {
     return database.Delete("client", new Dictionary<string, string>
     {
         {"client_id", c.ID}
     }) > 0;
 }
Ejemplo n.º 2
0
 public ClientInformation GetClientInformation(string id)
 {
     database.Open();
     DataTable result = database.Select("SELECT * FROM client where client_id = @client_id", new Dictionary<string, object>
     {
         {"@client_id", id}
     });
     if (result.Rows.Count == 0) throw new ArgumentException("There is no client_id " + id, "id");
     ClientInformation c = new ClientInformation();
     c.Fill(result.Rows[0]);
     database.Close();
     return c;
 }
Ejemplo n.º 3
0
        public List<ClientInformation> GetClientInformations()
        {
            database.Open();
            List<ClientInformation> r = new List<ClientInformation>();
            DataTable table = database.Select("select * from client");
            foreach (DataRow row in table.Rows)
            {
                ClientInformation c = new ClientInformation();
                c.Fill(row);
                r.Add(c);
            }

            database.Close();
            return r;
        }
Ejemplo n.º 4
0
        public List<BillInformation> GetAssociatedBills(CompanyInformation company, ClientInformation client)
        {
            List<BillInformation> bills = new List<BillInformation>();
            DataTable results = database.Select("SELECT * FROM bill WHERE company=@company AND client=@client",
                new Dictionary<string, object>()
                {
                    {"company", company.ID},
                    {"client", client.ID}
                });

            foreach (DataRow result in results.Rows)
            {
                BillInformation bill = new BillInformation();
                bill.Fill(result);
                bills.Add(bill);
            }
            return bills;
        }
Ejemplo n.º 5
0
 public List<ClientInformation> GetClientsByName(string name)
 {
     List<ClientInformation> list = new List<ClientInformation>();
     var result = database.Select("SELECT * FROM Client WHERE name = @name", new Dictionary<string, object>()
     {
         {"@name", name}
     });
     foreach (DataRow row in result.Rows)
     {
         ClientInformation c = new ClientInformation();
         c.Fill(row);
         list.Add(c);
     }
     return list;
 }
Ejemplo n.º 6
0
 public bool Update(ClientInformation c)
 {
     int rows = database.Update("client", new Dictionary<string, object>
     {
         { "name", c.Name },
         { "city", c.City },
         { "postal_code", c.PostalCode },
         { "address", c.Street }
     }, "client_id", c.ID);
     return rows > 0;
 }
Ejemplo n.º 7
0
 public void Insert(ClientInformation c)
 {
     database.Insert("client", new Dictionary<string, object>
     {
         { "client_id", null },
         { "name", c.Name },
         { "city", c.City },
         { "postal_code", c.PostalCode },
         { "address", c.Street }
     });
     c.ID = "" + database.LastInsertRowId();
 }