Exemple #1
0
        public bool add(string address)
        {
            Places place = new Serwis.Places {
                address = address
            };

            pe.Places.Add(place);
            try { pe.SaveChanges(); return(true); }
            catch { return(false); }
        }
Exemple #2
0
        /*
         * int column
         *      1 - name
         *      2 - city
         *      3 - street
         *      4 - houseNo
         *      5 - locumNo
         *      6 - phone
         *      7 - mail
         *      8 - nip
         */
        public bool edit(int column, int id, string value)
        {
            try
            {
                using (ProjektEntities pe = new ProjektEntities())
                {
                    var firm = pe.Firms.Find(id);
                    switch (column)
                    {
                    case 1: firm.name = value; break;

                    case 2: firm.city = value; break;

                    case 3: firm.street = value; break;

                    case 4: firm.house_no = value; break;

                    case 5: firm.locum_no = value; break;

                    case 6: firm.phone = value; break;

                    case 7: firm.mail = value; break;

                    case 8: firm.nip = value; break;
                    }
                    pe.SaveChanges();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #3
0
        /*
         * int column
         *      1 - name
         *      2 - surname
         *      3 - city
         *      4 - street
         *      5 - houseNo
         *      6 - locumNo
         *      7 - phone
         *      8 - mail
         */
        public bool edit(int column, int id, string value)
        {
            try
            {
                using (ProjektEntities pe = new ProjektEntities())
                {
                    var client = pe.Clients.Find(id);
                    switch (column)
                    {
                    case 1: client.name = value; break;

                    case 2: client.surname = value; break;

                    case 3: client.city = value; break;

                    case 4: client.street = value; break;

                    case 5: client.house_no = value; break;

                    case 6: client.locum_no = value; break;

                    case 7: client.phone = value; break;

                    case 8: client.mail = value; break;
                    }
                    pe.SaveChanges();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #4
0
        public bool add(bool firm, string model, string manufacturer, string serialNo, int deviceType, int statusId, int clientId)
        {
            // TODO: Add statuses
            try
            {
                if (firm == true)
                {
                    device = new DevicesCards {
                        manufacturer = manufacturer, model = model, serial_no = serialNo, type_id = deviceType, status_id = statusId, firm_id = clientId, created_at = DateTime.Now, updated_at = DateTime.Now
                    };
                }
                else
                {
                    device = new DevicesCards {
                        manufacturer = manufacturer, model = model, serial_no = serialNo, type_id = deviceType, status_id = statusId, client_id = clientId, created_at = DateTime.Now, updated_at = DateTime.Now
                    };
                }

                using (ProjektEntities pe = new ProjektEntities())
                {
                    pe.DevicesCards.Add(device);
                    pe.SaveChanges();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #5
0
        public bool add(string username, string password, int access_level, string place)
        {
            int   placeId = pe.Places.FirstOrDefault(p => p.address == place).id;
            Users user    = new Users {
                name = username, password = generateSha1(password), access_level = Convert.ToByte(access_level), place_id = placeId, created_at = DateTime.Now, updated_at = DateTime.Now
            };

            pe.Users.Add(user);
            try
            {
                pe.SaveChanges();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Exemple #6
0
 public bool delete(int id)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             var firm = pe.Firms.Find(id);
             pe.Firms.Remove(firm);
             pe.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #7
0
 public bool delete(int id)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             var deviceType = pe.DeviceTypes.Find(id);
             pe.DeviceTypes.Remove(deviceType);
             pe.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #8
0
 public bool edit(int id, string type)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             var deviceType = pe.DeviceTypes.Find(id);
             deviceType.type = type;
             pe.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #9
0
 public bool delete(int id)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             var client = pe.Clients.Find(id);
             pe.Clients.Remove(client);
             pe.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #10
0
 public bool delete(int id)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             var status = pe.Statuses.Find(id);
             pe.Statuses.Remove(status);
             pe.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #11
0
 public bool edit(int id, string statusName)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             var status = pe.Statuses.Find(id);
             status.name = statusName;
             pe.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #12
0
 public bool diagnosis(int id, string diag)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             var drc = pe.DeviceRepairCards.Find(id);
             drc.diagnosis  = diag;
             drc.updated_at = DateTime.Now;
             pe.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #13
0
 public bool makeRepaired(int id)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             var drc = pe.DeviceRepairCards.Find(id);
             drc.repaired   = true;
             drc.updated_at = DateTime.Now;
             pe.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #14
0
        public bool add(int id, string damageDesc)
        {
            User user = new User();

            try
            {
                using (ProjektEntities pe = new ProjektEntities())
                {
                    var repairCard = new DeviceRepairCards {
                        damage_desc = damageDesc, repaired = false, created_at = DateTime.Now, updated_at = DateTime.Now, device_id = id, place_id = user.from(user.getCurrentUserId())
                    };
                    pe.DeviceRepairCards.Add(repairCard);
                    pe.SaveChanges();
                }
                return(true);
            }
            catch { return(false); }
        }
Exemple #15
0
 public bool add(string statusName)
 {
     try
     {
         var status = new Statuses {
             name = statusName
         };
         using (ProjektEntities pe = new ProjektEntities())
         {
             pe.Statuses.Add(status);
             pe.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #16
0
 public bool add(string type)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             DeviceTypes deviceType = new DeviceTypes {
                 type = type
             };
             pe.DeviceTypes.Add(deviceType);
             pe.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #17
0
 public bool statusChange(int id, int status)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             var dc = pe.DevicesCards.Find(id);
             dc.status_id  = status;
             dc.updated_at = DateTime.Now;
             pe.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message);
         //System.Windows.Forms.MessageBox.Show(ex.InnerException.ToString());
         return(false);
     }
 }
Exemple #18
0
 override public bool addClient(string name, string surname, string city, string street, string houseNo, string locumNo, string phoneNo, string mail)
 {
     try
     {
         using (ProjektEntities pe = new ProjektEntities())
         {
             Clients client = new Clients {
                 name = name, surname = surname, city = city, street = street, house_no = houseNo, locum_no = locumNo, phone = phoneNo, mail = mail, created_at = DateTime.Now, updated_at = DateTime.Now
             };
             pe.Clients.Add(client);
             pe.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.InnerException.ToString());
         return(false);
     }
 }