Пример #1
0
 public DevicesCards getDeviceData(int id)
 {
     using (ProjektEntities pe = new ProjektEntities())
     {
         return(pe.DevicesCards.Find(id));
     }
 }
Пример #2
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);
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
 public Array list()
 {
     using (ProjektEntities pe = new ProjektEntities())
     {
         return(pe.Clients.OrderBy(f => f.Id).ToArray());
     }
 }
Пример #5
0
 public string getName(int id)
 {
     using (ProjektEntities pe = new ProjektEntities())
     {
         return(pe.DeviceTypes.Find(id).type);
     }
 }
Пример #6
0
 public Array list()
 {
     using (ProjektEntities pe = new ProjektEntities())
     {
         return(pe.Statuses.OrderBy(p => p.Id).ToArray());
     }
 }
Пример #7
0
 public string getName(int id)
 {
     using (ProjektEntities pe = new ProjektEntities())
     {
         return(pe.Statuses.Find(id).name);
     }
 }
Пример #8
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);
            }
        }
Пример #9
0
        public UserAdd(Home h)
        {
            InitializeComponent();
            this.home    = h;
            AcceptButton = addUser_button;
            User u = new User();

            if (!u.isSuperadmin())
            {
                user_type.Items.Remove("Superadministrator");
            }
            user_type.Text = user_type.Items[0].ToString();
            ProjektEntities pe = new ProjektEntities();

            if (u.isAdmin())
            {
                this.placeBox.Items.Add(new Place().getAddress(u.from(u.getCurrentUserId())));
                this.placeBox.Text = this.placeBox.Items[0].ToString();
            }
            if (u.isSuperadmin())
            {
                this.placeBox.Items.Remove(new Place().getAddress(u.from(u.getCurrentUserId())));
                foreach (var place in pe.Places)
                {
                    this.placeBox.Items.Add(place.address);
                }
            }
        }
Пример #10
0
 public string getName(int id)
 {
     using (ProjektEntities pe = new ProjektEntities())
     {
         var client = pe.Firms.Find(id);
         return(client.name + " ( firma - " + client.Id + ")");
     }
 }
Пример #11
0
 public string getName(int id)
 {
     using (ProjektEntities pe = new ProjektEntities())
     {
         var client = pe.Clients.Find(id);
         return(client.name + " " + client.surname + " ( indywidualny - " + client.Id + ")");
     }
 }
Пример #12
0
        public DataTable list()
        {
            List <DevicesCards> list;
            ProjektEntities     pe = new ProjektEntities();

            list = pe.DevicesCards.ToList();
            DataTable table = DataHelper.ToDataTable <DevicesCards>(list);

            table.Columns.Add();
            table.Columns.Add();
            table.Columns.Add();
            return(table);
        }
Пример #13
0
        public DataTable list(bool repaired, bool diagnosis, bool note, DateTime addFrom, DateTime addTo, bool addDate, DateTime editFrom, DateTime editTo, bool editDate, int placeId)
        {
            ProjektEntities          pe   = new ProjektEntities();
            User                     user = new User();
            List <DeviceRepairCards> list;

            list = pe.DeviceRepairCards.Where(drc => drc.repaired == repaired).ToList();
            // Filters:
            if (!user.isSuperadmin())
            {
                int from = user.from(user.getCurrentUserId());
                list = list.Where(drc => drc.place_id == from).ToList();
            }
            // Check if diagnosis is empty
            if (diagnosis == false)
            {
                list = list.Where(drc => drc.diagnosis == null).ToList();
            }
            else
            {
                list = list.Where(drc => drc.diagnosis != null).ToList();
            }
            // Check if repair note is empty
            if (note == false)
            {
                list = list.Where(drc => drc.repair_note == null).ToList();
            }
            else
            {
                list = list.Where(drc => drc.repair_note != null).ToList();
            }
            // Check add date
            if (addDate == true)
            {
                list = list.Where(drc => drc.created_at >= addFrom.ToUniversalTime()).Where(drc => drc.created_at <= addTo.ToUniversalTime()).ToList();
            }
            // Check edit date
            if (editDate == true)
            {
                list = list.Where(drc => drc.updated_at >= editFrom.ToUniversalTime()).Where(drc => drc.updated_at <= editTo.ToUniversalTime()).ToList();
            }
            // Admin can filter on Place
            if (placeId != 0)
            {
                list = list.Where(drc => drc.place_id == placeId).ToList();
            }
            DataTable table = DataHelper.ToDataTable <DeviceRepairCards>(list);

            table.Columns.Add();
            return(table);
        }
Пример #14
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);
     }
 }
Пример #15
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);
     }
 }
Пример #16
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);
     }
 }
Пример #17
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);
     }
 }
Пример #18
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);
     }
 }
Пример #19
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);
     }
 }
Пример #20
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);
     }
 }
Пример #21
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);
     }
 }
Пример #22
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); }
        }
Пример #23
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);
     }
 }
Пример #24
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);
     }
 }
Пример #25
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);
     }
 }
Пример #26
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);
     }
 }
Пример #27
0
        public void display()
        {
            User u = new User();

            userListGrid.DataSource = u.listUsers();
            ProjektEntities pe = new ProjektEntities();

            for (int i = 0; i < userListGrid.RowCount; i++)
            {
                userListGrid.Rows[i].Cells[8].Value = pe.Places.Find(Convert.ToInt32(userListGrid.Rows[i].Cells[6].Value)).address;
            }
            userListGrid.Columns[0].HeaderText = "ID";
            userListGrid.Columns[1].HeaderText = "Nazwa";
            userListGrid.Columns[2].Visible    = false;
            userListGrid.Columns[3].HeaderText = "Utworzony";
            userListGrid.Columns[4].HeaderText = "Zmodyfikowany";
            userListGrid.Columns[5].HeaderText = "Poziom uprawnień";
            userListGrid.Columns[6].Visible    = false;
            userListGrid.Columns[7].Visible    = false;
            userListGrid.Columns[8].HeaderText = "Miejsce";
        }
Пример #28
0
        public UserEdit(int id, Home t, UserList ul)
        {
            InitializeComponent();
            this.userid  = id;
            this.home    = t;
            this.ul      = ul;
            AcceptButton = editButton;
            User u = new User();

            if (!u.isSuperadmin())
            {
                type.Items.Remove("Superadministrator");
            }
            user_type.Text = user_type.Items[0].ToString();
            ProjektEntities pe = new ProjektEntities();

            foreach (var place in pe.Places)
            {
                this.place.Items.Add(place.address);
            }
        }