private void timer1_Tick(object sender, EventArgs e) { try { using (var db = new ProjeEntities()) { if (label1.Text != null) { label1.Text = null; label2.Text = null; label3.Text = null; label4.Text = null; } r.Connect(); var id = r.GetCardUID(); var emp = db.Employees.FirstOrDefault(x => x.CardNumber == id); if (emp != null) { label1.Text = emp.Name; label2.Text = emp.Surname; label3.Text = emp.CardNumber; LoginEmployee l = new LoginEmployee(); l.EmployeeId = emp.Id; DateTime localDate = DateTime.Now; l.Date = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss").ToString()); label4.Text = Convert.ToString(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss").ToString())); var s = r.Watch(); label4.Text = s; var sname = db.Shifts.Where(x => x.ShiftNumber == s).FirstOrDefault(); l.Shiftname = sname.Name; db.LoginEmployees.Add(l); db.SaveChanges(); } } } catch (Exception) { throw; } }
public JsonResult upde(string name, string surname, string username, string password, int id) { try { using (var db = new ProjeEntities()) { var emp = db.Employees.FirstOrDefault(x => x.Id == id); emp.Name = name; emp.Surname = surname; emp.Password = password; emp.UserName = username; db.SaveChanges(); return(Json("")); } } catch (Exception) { throw; } }
public JsonResult DeleteAnnouncements(int _id) { try { using (ProjeEntities db = new ProjeEntities()) { var ann = db.UserAnnouncements.Where(x => x.Id == _id).FirstOrDefault(); db.UserAnnouncements.Remove(ann); db.SaveChanges(); return(Json("Delete")); } } catch (Exception) { throw; } }
public JsonResult AddEmployeeShift(string _cardId, string _shiftid, string _start, string _finish) { try { using (var db = new ProjeEntities()) { EmployeeShift es = new EmployeeShift(); es.ShiftId = db.Shifts.Where(x => x.Name == _shiftid).Select(x => x.Id).FirstOrDefault(); es.EmployeeId = db.Employees.Where(x => x.CardNumber == _cardId).Select(x => x.Id).FirstOrDefault(); es.Finish = Convert.ToDateTime(_finish); es.Start = Convert.ToDateTime(_start); db.EmployeeShifts.Add(es); db.SaveChanges(); } } catch (Exception) { throw; } return(Json("a")); }
public JsonResult AddCompany(string name, string surname, string username, string password, string cname) { try { using (var db = new ProjeEntities()) { var dbo = DBO.GetInstance(); var u = dbo.AddUser(name, surname, username, password); var c = dbo.AddCompamy(cname); UserCompany uc = new UserCompany(); uc.UserId = u.Id; uc.CompanyId = c.Id; db.UserCompanies.Add(uc); db.SaveChanges(); return(Json("")); } } catch (Exception) { throw; } }
public JsonResult AddUsers(string name, string surname, string username, string password) { try { using (ProjeEntities db = new ProjeEntities()) { var dbo = DBO.GetInstance(); var cus = Session["UserCompany"] as UserCompany; var u = dbo.AddUser(name, surname, username, password); UserCompany uc = new UserCompany(); uc.UserId = u.Id; uc.CompanyId = (int)cus.CompanyId; db.UserCompanies.Add(uc); db.SaveChanges(); return(Json("")); } } catch (Exception exe) { throw; } }
public JsonResult DelAnn(int id) { try { using (var db = new ProjeEntities()) { var cus = Session["UserCompany"] as UserCompany; var dbo = ProjeDB.DBO.GetInstance(); var ua = dbo.delUserAnn(id); var c = dbo.delAnnCom(id); var a = db.Announcements.FirstOrDefault(x => x.Id == id); db.Announcements.Remove(a); db.SaveChanges(); return(Json("")); } } catch (Exception) { throw; } }