public void DeleteProduct(string id) { PrinteryContext pr = new PrinteryContext(); pr.Product.Remove(pr.Product.Where(p => p.ProductID == id).FirstOrDefault()); pr.SaveChanges(); }
public void DeleteEnployee(string empid) { PrinteryContext pr = new PrinteryContext(); pr.Employee.Remove(pr.Employee.Where(p => p.EmpId == empid).FirstOrDefault()); pr.SaveChanges(); }
public void DeleteCustomer(string cmsid) { PrinteryContext pr = new PrinteryContext(); pr.Customer.Remove(pr.Customer.Where(p => p.CustomerId == cmsid).FirstOrDefault()); pr.SaveChanges(); }
public void DeleteProExi(string proid) { PrinteryContext pr = new PrinteryContext(); pr.ProductionExpense.Remove(pr.ProductionExpense.Where(p => p.ProExId == proid).FirstOrDefault()); pr.SaveChanges(); }
public void DeleteInk(string inkid) { PrinteryContext pr = new PrinteryContext(); pr.InkStock.Remove(pr.InkStock.Where(p => p.InkId == inkid).FirstOrDefault()); pr.SaveChanges(); }
public void DeletePaper(string paperid) { PrinteryContext pr = new PrinteryContext(); pr.Paper.Remove(pr.Paper.Where(p => p.PaperId == paperid).FirstOrDefault()); pr.SaveChanges(); }
public void DeletePaperPurchase(string purchaseid) { PrinteryContext pr = new PrinteryContext(); pr.PaperPurchasing.Remove(pr.PaperPurchasing.Where(p => p.PurchasingID == purchaseid).FirstOrDefault()); pr.SaveChanges(); }
public void DeleteOrder(string orderid) { PrinteryContext pr = new PrinteryContext(); pr.Order.Remove(pr.Order.Where(p => p.OrderId == orderid).FirstOrDefault()); pr.SaveChanges(); //_db.Order.Remove(_db.Order.Where(p => p.OrderId == orderid).FirstOrDefault()); }
public void DeleteUserGroup(string GroupId) { PrinteryContext pr = new PrinteryContext(); pr.Database.ExecuteSqlCommand("DELETE FROM PowerControlList WHERE GroupId={0}", GroupId); pr.EmpGroup.Remove(pr.EmpGroup.Where(p => p.GroupId == GroupId).FirstOrDefault()); pr.SaveChanges(); }
public void AddUserGroupByGroupName(string GroupName) { PrinteryContext db = new PrinteryContext(); var newGroup = new EmpGroup() { GroupId = Guid.NewGuid().ToString(), GroupName = GroupName, Tip = "" }; db.EmpGroup.Add(newGroup); db.SaveChanges(); }
public void UpdatePassword(string pwd, string empid) { var db = new PrinteryContext(); var exitEmp = db.Employee.FirstOrDefault(s => s.EmpId == empid); if (exitEmp != null) { db.Set <Employee>().Attach(exitEmp); db.Entry(exitEmp).State = EntityState.Modified; exitEmp.Password = pwd; db.SaveChanges(); } }
public void EditInk(string inkid, string inkname) { var db = new PrinteryContext(); var exitInk = db.InkStock.FirstOrDefault(s => s.InkId == inkid); if (exitInk != null) { db.Set <InkStock>().Attach(exitInk); db.Entry(exitInk).State = EntityState.Modified; exitInk.InkName = inkname; db.SaveChanges(); } }
public void EditPaper(string paperid, string papername) { var db = new PrinteryContext(); var exitPaper = db.Paper.FirstOrDefault(s => s.PaperId == paperid); if (exitPaper != null) { db.Set <Paper>().Attach(exitPaper); db.Entry(exitPaper).State = EntityState.Modified; exitPaper.PaperName = papername; db.SaveChanges(); } }
public void EditProduct(ProductGoodsViewModel product) { var db = new PrinteryContext(); var exitProduct = db.Product.FirstOrDefault(s => s.ProductID == product.ProductID); if (exitProduct != null) { db.Set <Product>().Attach(exitProduct); db.Entry(exitProduct).State = EntityState.Modified; exitProduct.ProductName = product.ProductName; exitProduct.eachPrice = product.eachPrice; db.SaveChanges(); } }
public void AddCustomer(CustomerViewModel cms) { var db = new PrinteryContext(); var neWCus = new Customer() { CustomerId = Guid.NewGuid().ToString(), CustomerName = cms.CustomerName, Contact = cms.Contact, Phone = cms.Phone, MobilePhone = cms.MobilePhone, CAddress = cms.CAddress }; db.Customer.Add(neWCus); db.SaveChanges(); }
public void EditEmployee(EmployeeViewModel emp) { var db = new PrinteryContext(); var exitEmp = db.Employee.FirstOrDefault(s => s.EmpId == emp.EmpId); if (exitEmp != null) { db.Set <Employee>().Attach(exitEmp); db.Entry(exitEmp).State = EntityState.Modified; exitEmp.Ename = emp.Ename; exitEmp.Department = emp.Department; exitEmp.UserGroup = emp.UserGroup; exitEmp.Sex = emp.Sex; db.SaveChanges(); } }
public void UpdatePowerList(List <PowerControlListViewModel> powerlist) { PrinteryContext db = new PrinteryContext(); db.Database.ExecuteSqlCommand("DELETE FROM PowerControlList WHERE GroupId={0}", powerlist[0].GroupId); foreach (var item in powerlist) { var newItem = new PowerControlList() { ControlId = Guid.NewGuid().ToString(), PowerId = item.PowerId, GroupId = item.GroupId }; db.PowerControlList.Add(newItem); db.SaveChanges(); } }
public void EditCustomer(CustomerViewModel cms) { var db = new PrinteryContext(); var exitCms = db.Customer.FirstOrDefault(s => s.CustomerId == cms.CustomerId); if (exitCms != null) { db.Set <Customer>().Attach(exitCms); db.Entry(exitCms).State = EntityState.Modified; exitCms.CustomerName = cms.CustomerName; exitCms.Contact = cms.Contact; exitCms.Phone = cms.Phone; exitCms.MobilePhone = cms.MobilePhone; exitCms.CAddress = cms.CAddress; db.SaveChanges(); } }
public void AddEmployee(EmployeeViewModel emp) { PrinteryContext db = new PrinteryContext(); var newEmp = new Employee() { EmpId = Guid.NewGuid().ToString(), Ename = emp.Ename, Username = emp.Username, Password = emp.Password, Department = emp.Department, UserGroup = emp.UserGroup, Sex = emp.Sex }; db.Employee.Add(newEmp); db.SaveChanges(); }
public void UpdateEmployeeInfo(EmployeeViewModel emp) { var db = new PrinteryContext(); var exitEmp = db.Employee.FirstOrDefault(s => s.EmpId == emp.EmpId); if (exitEmp != null) { db.Set <Employee>().Attach(exitEmp); db.Entry(exitEmp).State = EntityState.Modified; exitEmp.Ename = emp.Ename; exitEmp.Department = emp.Department; exitEmp.Nation = emp.Nation; exitEmp.Sex = emp.Sex; exitEmp.QQ = emp.QQ; exitEmp.Phone = emp.Phone; db.SaveChanges(); } }
public void AddProExis(addProExiViewModel pro) { PrinteryContext pr = new PrinteryContext(); var ProExi = new ProductionExpense() { ProExId = Guid.NewGuid().ToString(), ProductId = pro.ProductId, ProductName = pro.ProductName, InkId1 = pro.InkId1, InkId2 = pro.InkId2, InkId1Count = pro.InkId1Count, InkId2Count = pro.InkId2Count, PaperId1 = pro.PaperId1, PaperId2 = pro.PaperId2, PaperId1Count = pro.PaperId1Count, PaperId2Count = pro.PaperId2Count }; pr.ProductionExpense.Add(ProExi); pr.SaveChanges(); }
public void EditProExi(addProExiViewModel pro) { PrinteryContext pr = new PrinteryContext(); var exitPro = pr.ProductionExpense.FirstOrDefault(s => s.ProExId == pro.ProExId); if (exitPro != null) { pr.Set <ProductionExpense>().Attach(exitPro); pr.Entry(exitPro).State = EntityState.Modified; exitPro.ProductId = pro.ProductId; exitPro.ProductName = pro.ProductName; exitPro.InkId1 = pro.InkId1; exitPro.InkId2 = pro.InkId2; exitPro.InkId1Count = pro.InkId1Count; exitPro.InkId2Count = pro.InkId2Count; exitPro.PaperId1 = pro.PaperId1; exitPro.PaperId2 = pro.PaperId2; exitPro.PaperId2Count = pro.PaperId2Count; pr.SaveChanges(); } }
public static void SeedDatabaseOrder(PrinteryContext db) { var _Order = new Order() { OrderId = "12345", OrderCreate = DateTime.Now, OrderProcess = DateTime.Now, CreatePersonId = "123345", CustomerId = "12345", Deadline = DateTime.Now, CustomerName = "12345", Status = "已完成", Price = 123, ProcessPersonId = "123", Phone = "1234", Email = "1234", Tips = "123", Addressed = "123456" }; db.Order.Add(_Order); db.SaveChanges(); }