public DevicesCards getDeviceData(int id) { using (ProjektEntities pe = new ProjektEntities()) { return(pe.DevicesCards.Find(id)); } }
/* * 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); } }
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); } }
public Array list() { using (ProjektEntities pe = new ProjektEntities()) { return(pe.Clients.OrderBy(f => f.Id).ToArray()); } }
public string getName(int id) { using (ProjektEntities pe = new ProjektEntities()) { return(pe.DeviceTypes.Find(id).type); } }
public Array list() { using (ProjektEntities pe = new ProjektEntities()) { return(pe.Statuses.OrderBy(p => p.Id).ToArray()); } }
public string getName(int id) { using (ProjektEntities pe = new ProjektEntities()) { return(pe.Statuses.Find(id).name); } }
/* * 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); } }
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); } } }
public string getName(int id) { using (ProjektEntities pe = new ProjektEntities()) { var client = pe.Firms.Find(id); return(client.name + " ( firma - " + client.Id + ")"); } }
public string getName(int id) { using (ProjektEntities pe = new ProjektEntities()) { var client = pe.Clients.Find(id); return(client.name + " " + client.surname + " ( indywidualny - " + client.Id + ")"); } }
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); }
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); }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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"; }
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); } }