// יציאה של עובד שומר במסד נתונים ת שעת היציאה של העובד public static UserCalandarDTO SingOut(int id, DateTime date) { using (restaurantEntities db = new restaurantEntities()) { Employees emm = db.Employees.FirstOrDefault(e => e.Id == id); if (emm != null) { UserCalander userCalandar = db.UserCalander.FirstOrDefault(u => u.IdUser == id && u.Date.Value.Year == date.Year && u.Date.Value.Month == date.Month && u.Date.Value.Day == date.Day); if (userCalandar != null) { userCalandar.LeavingTime = date; db.Entry(userCalandar).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(UserCalandarC.ToDTO(userCalandar)); } else { return(null); } } Visiters visiter = db.Visiters.FirstOrDefault(e => e.ld == id); if (visiter != null) { visiter.lastDateEnter = date; db.Entry(visiter).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(null); } }
// שמירת המשמרות של עובד לתאריך מסוים public static string AddShifttoNextWeekEmployee(List <calandar> calandarList, int userID) { using (restaurantEntities db = new restaurantEntities()) { foreach (var item in calandarList) { UserCalander userCalandar = db.UserCalander.FirstOrDefault(u => u.IdUser == userID && u.Date.Value.Year == item.date.Year && u.Date.Value.Month == item.date.Month && u.Date.Value.Day == item.date.Day); if (userCalandar != null) { userCalandar.Shift = item.shift; db.Entry(userCalandar).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } else { UserCalander userC = new UserCalander(); userC.IdUser = userID; userC.Date = item.date; userC.Shift = item.shift; db.UserCalander.Add(userC); db.SaveChanges(); } } return("השינויים נשמרו"); } }
public bool addAccountAndTable(String username, String password, int accTypeId, int tableNumber) { using (restaurantEntities context = new restaurantEntities()) { try { account newAcc = new account { username = username, password = password, AccountType_id = accTypeId, active = 1 }; context.account.Add(newAcc); context.SaveChanges(); table newTable = new table { number = tableNumber, Account_id = newAcc.id }; context.table.Add(newTable); context.SaveChanges(); return(true); } catch { return(false); } } }
protected void Ekle_Click(object sender, EventArgs e) { Models.Entity.menu m = new Models.Entity.menu(); m.ad = TextBoxad.Text; m.icindekiler = TextBoxicindekler.Text; m.fiyat = Convert.ToDecimal(TextBoxfiyat.Text); m.kategoriId = Convert.ToInt32(DropDownListkategori.SelectedItem.Value); m.resim = TextBoxresim.Text; db.menus.Add(m); db.SaveChanges(); Response.Redirect("/admin/menu.aspx"); }
public bool addItem(String name, String description, int typeId, decimal price, String image_path) { using (restaurantEntities context = new restaurantEntities()) { try { item newItem = new item { name = name, description = description, ItemType_id = typeId, image_path = image_path, active = 1, price = price }; context.item.Add(newItem); context.SaveChanges(); return(true); } catch { return(false); } } }
// הוספת הודעה public static managerMessageDTO SendManagerMassegeToEmloyee(managerMessageDTO messege) { using (restaurantEntities db = new restaurantEntities()) { managerMessage m = managerMessageDTO.ConvertDonationToTabel(messege); db.managerMessage.Add(m); db.SaveChanges(); return(messege); } }
// פונקצית כניסה עובד או לקוח אם הןא עובד נוסף עוד יום ביון העובד עם שעת הכניסה הנוכחי public static object SineIn(string name, string password) { using (restaurantEntities db = new restaurantEntities()) { // עם המשתשמש מסוג עובד Employees employees = db.Employees.FirstOrDefault (e => e.FirstName.Equals(name) && e.Password.Equals(password)); if (employees != null) { UserCalander userCalandar = db.UserCalander.FirstOrDefault(u => u.IdUser == employees.Id && u.Date.Value.Year == DateTime.Today.Year && u.Date.Value.Month == DateTime.Today.Month && u.Date.Value.Day == DateTime.Today.Day); // עם יש למשתמש יום ביומן בתאריך של היום רק לעדכן את שעת הכניסה if (userCalandar != null) { userCalandar.EntranceTime = DateTime.Now; db.Entry(userCalandar).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } // אם אין לו יום ביומן בתאריך של היום מוסיך תאריך חדש else { UserCalander userC = new UserCalander(); userC.IdUser = employees.Id; userC.Date = DateTime.Today; userC.EntranceTime = DateTime.Now; db.UserCalander.Add(userC); db.SaveChanges(); } return(EmployeesDTO.ConvertDonationToDTO(employees)); } // אם המשתמש הוא מסוג לקוח Visiters visiter = db.Visiters.FirstOrDefault(v => v.NameUser.Equals(name) && v.Password.Equals(password)); if (visiter != null) { return(VisitersCast.ToDTO(visiter)); } // אם המשתמש לא רשום במערכתת return(null); } }
public static managerMessageDTO EditReadMessege(managerMessageDTO messege) { using (restaurantEntities db = new restaurantEntities()) { messege.AlreadyRead = true; managerMessage m = managerMessageDTO.ConvertDonationToTabel(messege); db.Entry(m).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(messege); } }
public int addOrder(List <OrderItemCustom> orderItems, decimal totalPrice, int tableId) { using (restaurantEntities context = new restaurantEntities()) { try { //first we create the order object order newOrder = new order { date = DateTime.Now, time = DateTime.Now.TimeOfDay, total = totalPrice, accepted = 0, Table_id = tableId }; context.order.Add(newOrder); context.SaveChanges(); //creating order items foreach (var item in orderItems) { orderitem newOrderItem = new orderitem { Order_id = newOrder.id, Item_id = item.id, quantity = item.quantity, price = item.price }; context.orderitem.Add(newOrderItem); } context.SaveChanges(); return(newOrder.id); } catch (Exception ex) { return(0); } } }
// מחיקת עובד ממשרת מסוימת ע" מנהל public static string DeleteEmployeeShirt(DateTime date, int IdUser) { using (restaurantEntities db = new restaurantEntities()) { UserCalander userCalandar = db.UserCalander.FirstOrDefault(u => u.IdUser == IdUser && u.Date.Value.Year == date.Year && u.Date.Value.Month == date.Month && u.Date.Value.Day == date.Day); if (userCalandar != null) { db.UserCalander.Remove(userCalandar); db.SaveChanges(); } return("משמרת העובד הוסרה מהמערכת!! "); } }
public bool acceptOrder(int orderId) { using (restaurantEntities context = new restaurantEntities()) { try { order requested = context.order.Where(o => o.id == orderId).First(); requested.accepted = 1; context.SaveChanges(); return(true); }catch { return(false); } } }
public bool changeActiveStatus(int accId, int newState) { using (restaurantEntities context = new restaurantEntities()) { try { account toChange = context.account.Where(i => i.id == accId).ToList().First(); toChange.active = (sbyte)newState; context.SaveChanges(); return(true); } catch { return(false); } } }
public bool updatePassword(int accountId, String newPassword) { using (restaurantEntities context = new restaurantEntities()) { try { account toUpdate = context.account.Where(a => a.id == accountId).First(); toUpdate.password = newPassword; context.SaveChanges(); return(true); } catch { return(false); } } }
public bool updateItem(int itemId, String name, String description, int typeId, decimal price, String image_path) { using (restaurantEntities context = new restaurantEntities()) { try { item toUpdate = context.item.Where(i => i.id == itemId).First(); toUpdate.name = name; toUpdate.description = description; toUpdate.ItemType_id = typeId; toUpdate.price = price; toUpdate.image_path = image_path; context.SaveChanges(); return(true); } catch { return(false); } } }
public bool addAccount(String username, String password, int accTypeId) { using (restaurantEntities context = new restaurantEntities()) { try { account newAcc = new account { username = username, password = password, AccountType_id = accTypeId, active = 1 }; context.account.Add(newAcc); context.SaveChanges(); return(true); } catch { return(false); } } }
//שינוי משמרות לפי תאריך לעובד מסוים ע"י מנהל public static string PutShiftToEmployee(DateTime date, int IdUser) { using (restaurantEntities db = new restaurantEntities()) { UserCalander userCalandar = db.UserCalander.FirstOrDefault(u => u.IdUser == IdUser && u.Date.Value.Year == date.Year && u.Date.Value.Month == date.Month && u.Date.Value.Day == date.Day); if (userCalandar != null) { if (userCalandar.Shift == "morning") { userCalandar.Shift = "evening"; } else { userCalandar.Shift = "morning"; } db.Entry(userCalandar).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return("עודכן משמרת "); } }
public ActionResult Nuevo() { try { string nombre = Request.Form["User"].ToString(); int telefono = int.Parse(Request.Form["telefono"].ToString()); string ubicacion = Request.Form["ubicacion"].ToString(); string contrasenia = Request.Form["password"].ToString(); using (var db = new restaurantEntities()) { var d = new cliente(); d.nombrecompleto = nombre; d.telefono = telefono; d.ubicacion = ubicacion; d.contraseña = contrasenia; d.rolCli = 3; db.cliente.Add(d); db.SaveChanges(); userr.id = 3; userr.email = "*****@*****.**"; userr.idRol = 3; userr.nombre = d.nombrecompleto; userr.password = d.contraseña; userr.IdUser = d.id; Session["User"] = userr; } return(RedirectToAction("Catalogo", "Productos")); } catch (Exception w) { ViewBag.Error = w.Message; return(View()); } }