public int Add(decimal GST, decimal GSTamount, decimal Discount, decimal GrandTotal, int Supplier_ID, decimal Quantity, decimal Transport_Charge, decimal OtherExpences, string Comment, string PaymentMode, decimal Subtotal, int Id) { string Company_Id = string.Empty; HttpCookie myCookie = Request.Cookies["inventoryCookie"]; if (!string.IsNullOrEmpty(myCookie.Values["Company_Id"])) { Company_Id = myCookie.Values["Company_Id"].ToString(); } var compid = Convert.ToInt32(Company_Id); Purchase_Bill purchase = new Purchase_Bill(); if (Id != 0) { purchase = db.Purchase_Bill.Where(e => e.Bill_No == Id).FirstOrDefault(); purchase.Date_Modified = DateTime.Now; } else { purchase.Date_Created = DateTime.Now; } purchase.Date_Created = DateTime.Now; purchase.Company_Id = compid; purchase.Supplier_ID = Supplier_ID; purchase.Quantity = Quantity; purchase.Discount = Discount; purchase.GST_Amount = GSTamount; purchase.Total_Amount = GrandTotal; purchase.Comment = Comment; purchase.Transport_Charges = Transport_Charge; purchase.Other_Expenses = OtherExpences; purchase.Payment_Mode = PaymentMode; purchase.GST = GST; purchase.SubTotal = Subtotal; db.Purchase_Bill.Add(purchase); if (Id != 0) { db.Entry(purchase).State = EntityState.Modified; } else { db.Purchase_Bill.Add(purchase); } db.SaveChanges(); var Bill_Id = db.Purchase_Bill.Where(e => e.Company_Id == compid && e.Supplier_ID == Supplier_ID && e.Total_Amount == GrandTotal).Select(e => e.Bill_No).FirstOrDefault(); return(Bill_Id); }
// Add Function public int Add(decimal GSTamount, decimal Discount, decimal GrandTotal, int Customer_ID, decimal Quantity, decimal delivery, decimal OtherExpences, string Comment, string PaymentMode, decimal Subtotal, decimal GST, int?Id) { string Company_Id = string.Empty; HttpCookie myCookie = Request.Cookies["inventoryCookie"]; if (!string.IsNullOrEmpty(myCookie.Values["Company_Id"])) { Company_Id = myCookie.Values["Company_Id"].ToString(); } var compid = Convert.ToInt32(Company_Id); Sales_Bill sales_Bill = new Sales_Bill(); if (Id != 0) { sales_Bill = db.Sales_Bill.Where(e => e.Sales_Bill_No == Id).FirstOrDefault(); sales_Bill.Date_Modified = DateTime.Now; } else { sales_Bill.Date_Created = DateTime.Now; } sales_Bill.Company_ID = compid; sales_Bill.Delivery = delivery; sales_Bill.Discount = Discount; sales_Bill.Customer_ID = Customer_ID; sales_Bill.GST_Amount = GSTamount; sales_Bill.Quantity = Quantity; sales_Bill.Other_Expenses = OtherExpences; sales_Bill.Payment_Mode = PaymentMode; sales_Bill.Comment = Comment; sales_Bill.Total_Amount = GrandTotal; sales_Bill.GST = GST; sales_Bill.SubTotal = Subtotal; if (Id != 0) { db.Entry(sales_Bill).State = EntityState.Modified; } else { db.Sales_Bill.Add(sales_Bill); } db.SaveChanges(); var Sales_Bill_Id = db.Sales_Bill.Where(e => e.Company_ID == compid && e.Customer_ID == Customer_ID && e.Total_Amount == GrandTotal).Select(e => e.Sales_Bill_No).FirstOrDefault(); return(Sales_Bill_Id); }
public IHttpActionResult PutCourse(int id, [FromBody] Course course) { if (id != course.ID) { return(BadRequest()); } db.Entry(course).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult InsertEmployee([DataSourceRequest] DataSourceRequest request, Employee addEmployee) { if (ModelState.IsValid) { if (TempData["facId"] != null) { if (addEmployee.EmployeeId == 0) { string FID = Convert.ToString(TempData["facId"]); var id = int.Parse(FID); addEmployee.FacilityId = id; db.Employees.Add(addEmployee); db.SaveChanges(); } else { db.Entry(addEmployee).State = EntityState.Modified; db.Employees.Add(addEmployee); db.SaveChanges(); } } } return(Json(new[] { addEmployee }.ToDataSourceResult(request))); }
public IHttpActionResult Putcliente(int id, cliente cliente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cliente.id_cliente) { return(BadRequest()); } db.Entry(cliente).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!clienteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public Dictionary <string, object> FindPassword(string name, string phone, string oldPassword, string NewPassword) { Dictionary <string, object> results = new Dictionary <string, object>(); bool operate = false; User user = FindUserByPhone(phone); if (user != null && user.name.Equals(name) && user.password.Equals(oldPassword)) { user.password = NewPassword; db.Entry <User>(user).State = EntityState.Modified; if (db.SaveChanges() > 0) { operate = true; } } results.Add("operate", operate); return(results); }
/// <summary> /// 修改实例 /// </summary> /// <param name="instance">实例对象</param> /// <returns>操作成功返回true,操作失败返回false</returns> public MainResponse.DefaultResponse ModifyInstance(Instance instance) { bool operate = false; if (InstanceExists(instance.id)) { db.Entry(instance).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { operate = true; } } return(new MainResponse.DefaultResponse() { operate = operate }); }
public MainResponse.DefaultResponse FindPassword(UserRequest.FindPassword parameters) { bool operate = false; User user = FindUserByPhone(parameters.phone); if (user != null && user.name.Equals(parameters.name) && user.password.Equals(parameters.oldPassword)) { user.password = parameters.newPassword; db.Entry <User>(user).State = EntityState.Modified; if (db.SaveChanges() > 0) { operate = true; } } return(new MainResponse.DefaultResponse() { operate = operate }); }
public bool ModifyResource(Resource resource) { db.Entry(resource).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { return(true); } return(false); }
public bool ModifyInstance(Instance instance) { db.Entry(instance).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { return(true); } return(false); }
public bool ModifyExpandKnowledge(ExpandKnowledge expandKnowledge) { db.Entry(expandKnowledge).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { return(true); } return(false); }
public bool ModifyExhibition(Exhibition exhibition) { db.Entry(exhibition).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { return(true); } return(false); }
public bool ModifyAdvanceKnowledge(AdvanceKnowledge advanceKnowledge) { db.Entry(advanceKnowledge).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { return(true); } return(false); }
public bool EditUser(User user) { if (user != null) { db.Entry(user).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { return(true); } } return(false); }
public MainResponse.DefaultResponse ModifyUploadRecordForTeacher(UploadRecordForTeacher uploadRecordForTeacher) { bool operate = false; if (UploadRecordForTeacherExists(uploadRecordForTeacher.sourceId)) { db.Entry(uploadRecordForTeacher).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { operate = true; } } return(new MainResponse.DefaultResponse() { operate = operate }); }
public MainResponse.DefaultResponse ModifyExhibition(Exhibition exhibition) { bool operate = false; if (ExhibitionExists(exhibition.id)) { db.Entry(exhibition).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { operate = true; } } return(new MainResponse.DefaultResponse() { operate = operate }); }
public MainResponse.DefaultResponse ModifyExpandKnowledge(ExpandKnowledge expandKnowledge) { bool operate = false; if (ExpandKnowledgeExists(expandKnowledge.id)) { db.Entry(expandKnowledge).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { operate = true; } } return(new MainResponse.DefaultResponse() { operate = operate }); }
public MainResponse.DefaultResponse ModifyResourceType(ResourceType resourceType) { bool operate = false; if (ResourceTypeExists(resourceType.id)) { db.Entry(resourceType).State = EntityState.Modified; int count = db.SaveChanges(); if (count != 0) { operate = true; } } return(new MainResponse.DefaultResponse() { operate = operate }); }
public ActionResult Edit(UserDetail user) { var usr = db.UserDetails.Find(user.UserId); usr.Address = user.Address; usr.Age = user.Age; usr.Company_Id = user.Company_Id; usr.Date_Modified = DateTime.Now; usr.Email = user.Email; usr.Gender = user.Gender; usr.Mobile = user.Mobile; usr.Name = user.Name; usr.Password = user.Password; usr.Role = "Admin"; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Default", new { area = "Auth" })); }
public ActionResult Edit(Company_Details company_Details) { if (ModelState.IsValid) { Company_Details com = db.Company_Details.Find(company_Details.Company_Id); com.Date_Modified = DateTime.Now; com.Address = company_Details.Address; com.City = company_Details.City; com.State = company_Details.State; com.Date_Of_Start = company_Details.Date_Of_Start; com.Date_Of_End = company_Details.Date_Of_End; com.Email = company_Details.Email; com.Mobile = company_Details.Mobile; com.Name = company_Details.Name; com.PrimaryContactPerson = company_Details.PrimaryContactPerson; db.Entry(com).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(company_Details)); }
public ActionResult InsertEmployee([DataSourceRequest] DataSourceRequest request, Employee addEmployee) { if (ModelState.IsValid) { if (addEmployee.EmployeeId == 0) { var FID = TempData["facId"]; addEmployee.FacilityId = (int?)FID; db.Employees.Add(addEmployee); db.SaveChanges(); } else { db.Entry(addEmployee).State = EntityState.Modified; db.Employees.Add(addEmployee); db.SaveChanges(); } } return(Json(new[] { addEmployee }.ToDataSourceResult(request))); }
public string Add(string category, string name, string Description, int Id) { string Returns = ""; if (ModelState.IsValid) { string Company_Id = string.Empty; string UserId = string.Empty; string UserName = string.Empty; HttpCookie myCookie = Request.Cookies["inventoryCookie"]; if (myCookie == null) { return("Logout"); } if (!string.IsNullOrEmpty(myCookie.Values["Company_Id"])) { Company_Id = myCookie.Values["Company_Id"].ToString(); } if (!string.IsNullOrEmpty(myCookie.Values["UserId"])) { UserId = myCookie.Values["UserId"].ToString(); } if (!string.IsNullOrEmpty(myCookie.Values["UserName"])) { UserName = myCookie.Values["UserName"].ToString(); } int company_Id = Convert.ToInt32(Company_Id); if (Id != 0) { Products_Details prds = db.Products_Details.Find(Id); prds.Category_Id = Convert.ToInt32(category); prds.Modified_By = UserName; prds.Date_Modified = DateTime.Now; prds.Description = Description; prds.Name = name; db.Entry(prds).State = EntityState.Modified; db.SaveChanges(); return("Product Upadated Successfully"); } Products_Details prd = db.Products_Details.Where(e => e.Company_Id == company_Id && e.Name == name).FirstOrDefault(); if (prd == null) { Products_Details products_Details = new Products_Details(); products_Details.Company_Id = company_Id; products_Details.Category_Id = Convert.ToInt32(category); products_Details.Created_By = UserName; products_Details.Date_Created = DateTime.Now; products_Details.Description = Description; products_Details.Name = name; db.Products_Details.Add(products_Details); db.SaveChanges(); return("Product Added Successfully"); } else { return("Product Already Exist"); } } return(Returns); }
public string Add(string name, int Id) { string Returns = ""; if (ModelState.IsValid) { string Company_Id = string.Empty; string UserId = string.Empty; string UserName = string.Empty; HttpCookie myCookie = Request.Cookies["inventoryCookie"]; if (myCookie == null) { return("Logout"); } if (!string.IsNullOrEmpty(myCookie.Values["Company_Id"])) { Company_Id = myCookie.Values["Company_Id"].ToString(); } if (!string.IsNullOrEmpty(myCookie.Values["UserId"])) { UserId = myCookie.Values["UserId"].ToString(); } if (!string.IsNullOrEmpty(myCookie.Values["UserName"])) { UserName = myCookie.Values["UserName"].ToString(); } int company_Id = Convert.ToInt32(Company_Id); if (Id != 0) { Units_Details units = db.Units_Details.Where(e => e.Unit_Id == Id).FirstOrDefault(); units.Company_Id = company_Id; units.Created_By = UserName; units.Date_Created = DateTime.Now; units.Name = name; db.Entry(units).State = EntityState.Modified; db.SaveChanges(); return("Unit Updated Successfully"); } else { Units_Details units = db.Units_Details.Where(e => e.Name == name && e.Company_Id == company_Id).FirstOrDefault(); if (units == null) { Units_Details units_Details = new Units_Details(); units_Details.Company_Id = company_Id; units_Details.Created_By = UserName; units_Details.Date_Created = DateTime.Now; units_Details.Date_Modified = DateTime.Now; units_Details.Name = name; db.Units_Details.Add(units_Details); db.SaveChanges(); return("Unit Added Successfully"); } else { return("Unit Already Exist"); } } } return(Returns); }
// Add function public string Add(string name, string email, string mobile, string address, int Id) { string Returns = ""; if (ModelState.IsValid) { string Company_Id = string.Empty; string UserId = string.Empty; string UserName = string.Empty; HttpCookie myCookie = Request.Cookies["inventoryCookie"]; if (myCookie == null) { return("Logout"); } if (!string.IsNullOrEmpty(myCookie.Values["Company_Id"])) { Company_Id = myCookie.Values["Company_Id"].ToString(); } if (!string.IsNullOrEmpty(myCookie.Values["UserId"])) { UserId = myCookie.Values["UserId"].ToString(); } if (!string.IsNullOrEmpty(myCookie.Values["UserName"])) { UserName = myCookie.Values["UserName"].ToString(); } int company_Id = Convert.ToInt32(Company_Id); if (Id != 0) { Supplier_Details supplier = db.Supplier_Details.Where(e => e.Supplier_Id == Id).FirstOrDefault(); supplier.Company_Id = company_Id; supplier.Created_By = UserName; supplier.Date_Created = DateTime.Now; supplier.Name = name; supplier.Email = email; supplier.Date_Modified = DateTime.Now; supplier.Mobile = mobile; supplier.Address = address; db.Entry(supplier).State = EntityState.Modified; db.SaveChanges(); return("Supplier Updated Successfully"); } else { Supplier_Details supplier = db.Supplier_Details.Where(e => e.Name == name && e.Company_Id == company_Id).FirstOrDefault(); if (supplier == null) { Supplier_Details supplier_Details = new Supplier_Details(); supplier_Details.Company_Id = company_Id; supplier_Details.Created_By = UserName; supplier_Details.Date_Created = DateTime.Now; supplier_Details.Name = name; supplier_Details.Email = email; supplier_Details.Mobile = mobile; supplier_Details.Address = address; db.Supplier_Details.Add(supplier_Details); db.SaveChanges(); return("Supplier Added Successfully"); } else { return("Supplier Already Exist"); } } } return(Returns); }
public string Add(string name, int Id) { string Returns = ""; if (ModelState.IsValid) { string Company_Id = string.Empty; string UserId = string.Empty; string UserName = string.Empty; HttpCookie myCookie = Request.Cookies["inventoryCookie"]; if (myCookie == null) { Returns = "Logout"; } if (!string.IsNullOrEmpty(myCookie.Values["Company_Id"])) { Company_Id = myCookie.Values["Company_Id"].ToString(); } if (!string.IsNullOrEmpty(myCookie.Values["UserId"])) { UserId = myCookie.Values["UserId"].ToString(); } if (!string.IsNullOrEmpty(myCookie.Values["UserName"])) { UserName = myCookie.Values["UserName"].ToString(); } int companyId = Convert.ToInt32(Company_Id); if (Id != 0) { Category_Details cart = db.Category_Details.Where(e => e.Category_Id == Id).FirstOrDefault(); cart.Modified_By = UserName; cart.Date_Modified = DateTime.Now; cart.Name = name; db.Entry(cart).State = EntityState.Modified; db.SaveChanges(); Returns = " Category Updated Successfully"; } else { Category_Details car = db.Category_Details.Where(e => e.Company_Id == companyId && e.Name == name).FirstOrDefault(); if (car == null) { Category_Details cart = new Category_Details(); cart.Added_By = UserName; cart.Date_Created = DateTime.Now; cart.Company_Id = Convert.ToInt32(Company_Id); cart.Name = name; db.Category_Details.Add(cart); db.SaveChanges(); Returns = " Category Added Successfully"; } else { Returns = "Category Already Exist"; } } } return(Returns); }