public bool AddSupplier(SupplierVM _SupplierVM) { try { tblSupplier supplier = new tblSupplier(); supplier.Address = _SupplierVM.Address; supplier.CST = _SupplierVM.CST; supplier.District = _SupplierVM.District; supplier.Email = _SupplierVM.Email; supplier.IsActive = _SupplierVM.IsActive; supplier.MobileNo1 = _SupplierVM.MobileNo1; supplier.MobileNo2 = _SupplierVM.MobileNo2; supplier.Owner = _SupplierVM.Owner; supplier.PinCode = _SupplierVM.PinCode; supplier.State = _SupplierVM.State; supplier.SupplierCode = _SupplierVM.SupplierCode; supplier.SupplierName = _SupplierVM.SupplierName; supplier.TelePhone1 = _SupplierVM.TelePhone1; supplier.TelePhone2 = _SupplierVM.TelePhone2; supplier.VAT = _SupplierVM.VAT; supplier.IsDeleted = false; _SupplierRepository.Add(supplier); _unitOfWork.Complete(); return(true); } catch (Exception e) { throw e; } }
public JsonResult AddSupplier(VM_Supplier supplier) { if (ModelState.IsValid) { try { tblSupplier aSupplier = new tblSupplier(); aSupplier.CompanyName = supplier.CompanyName; aSupplier.Address = supplier.Address; aSupplier.ContactNo = supplier.ContactNo; aSupplier.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aSupplier.CreatedBy = SessionManger.LoggedInUser(Session); aSupplier.CreatedDateTime = DateTime.Now; aSupplier.EditedBy = null; aSupplier.EditedDateTime = null; unitOfWork.SupplierRepository.Insert(aSupplier); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Supplier Added Successfully!" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Fill Up all required filled" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(VM_Supplier supplier) { if (ModelState.IsValid) { try { tblSupplier aSupplier = unitOfWork.SupplierRepository.GetByID(supplier.SupplierId); aSupplier.CompanyName = supplier.CompanyName; aSupplier.Address = supplier.Address; aSupplier.ContactNo = supplier.ContactNo; aSupplier.EditedBy = SessionManger.LoggedInUser(Session); aSupplier.EditedDateTime = DateTime.Now; unitOfWork.SupplierRepository.Update(aSupplier); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Supplier Info update successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Enter All required Field" }, JsonRequestBehavior.AllowGet)); } }
public string GetSupplierbyCode(string code) { tblSupplier supplier = _supplierrepo.Get_SupplierbyCode(code.ToLower()); string myJsonString = (new JavaScriptSerializer()).Serialize(supplier); return(myJsonString); }
//Get:Get Supplier For Update private void GetSupplierForUpdate() { if (Request.QueryString["Id"] != null) { txtcode.Enabled = false; divoptions.Style.Add("display", "block"); int id = Convert.ToInt32(Request.QueryString["Id"].ToString()); tblSupplier supplier = repo.Get_SupplierById(id); if (supplier != null) { txtcode.Text = supplier.Code.ToString(); txtName.Text = supplier.Name.ToString(); txtaddress1.Text = supplier.Address1.ToString(); txtaddress2.Text = supplier.Address2.ToString(); txtcity.Text = supplier.City.ToString(); txtstate.Text = supplier.State.ToString(); txtcountry.Text = supplier.Country.ToString(); txtgstno.Text = supplier.GSTNo.ToString(); txtpanno.Text = supplier.PanNo.ToString(); txtperson.Text = supplier.ContactPerson.ToString(); txtmobile.Text = supplier.ContactMobile.ToString(); txtemail.Text = supplier.ContactEMail.ToString(); } } }
public ActionResult LeadTime(int?id, string E) { if (id > 0 && E == "D") { tblSupplier model = db.tblSupplier.Find(id); db.Entry(model).State = EntityState.Deleted; db.SaveChanges(); TempData["msg"] = "Deleted Sucessfully!"; return(RedirectToAction("LeadTimeDetails")); } else if (id > 0) { tblSupplier model = db.tblSupplier.Find(id); return(View(model)); } else { var Supplier = (from x in UnitOfWork.UserRepository.GetAll().Where(x => x.UserType == "Supplier") select new SelectListItem { Value = x.Id.ToString(), Text = x.FirstName }).ToList(); ViewBag.supplierName = Supplier; return(View()); } }
public bool SaveChangesSupplier(tblSupplier model) { using (var dbContextTransaction = _db.Database.BeginTransaction()) { try { tblSupplier item = _db.Suppliers.Where(x => x.id == model.id).FirstOrDefault(); item.name = model.name; item.surname = model.surname; item.email = model.email; item.description = model.description; item.company = model.company; item.code = model.code; item.phone1 = model.phone1; item.phone2 = model.phone2; item.address = model.address; _db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception) { dbContextTransaction.Rollback(); return(false); } } }
public int DeleteSupplier(int supplierid) { tblSupplier ts = _db.tblSuppliers.Where(s => s.S_ID == supplierid).FirstOrDefault(); _db.tblSuppliers.Remove(ts); return(_db.SaveChanges()); }
public async Task <int> SaveSupplier(tblSupplier tblSupplier) { _context.tblSuppliers.Add(tblSupplier); int results = await _context.SaveChangesAsync(); return(results); }
public ActionResult LeadTime(int?Id, tblSupplier model) { if (Id > 0) { //var supplierid=UnitOfWork.UserRepository.Get(x=>x.Id==model. db.Entry(model).State = EntityState.Modified; db.SaveChanges(); TempData["msg"] = "Updated Sucessfully!"; ModelState.Clear(); } else { tblSupplier supplier = new tblSupplier(); supplier.SupplierID = Convert.ToInt64(model.SupplierName); int id = Convert.ToInt32(model.SupplierName); var Name = db.Users.Where(x => x.Id == id).Select(x => x.FirstName).FirstOrDefault(); supplier.SupplierName = Name.ToString(); supplier.LeadTime = model.LeadTime; db.tblSupplier.Add(supplier); db.SaveChanges(); TempData["msg"] = "Added Sucessfully!"; ModelState.Clear(); } return(RedirectToAction("LeadTimeDetails")); }
protected override void ExecuteCommand() { if (!MSPViewModel.IsSaveButtonCanPerform) { App.Current.ShowApplicationMessageBox("Kiểm tra lại tên và số điện thoại của nhà cung cấp!", HPSolutionCCDevPackage.netFramework.AnubisMessageBoxType.Default, HPSolutionCCDevPackage.netFramework.AnubisMessageImage.Hand, OwnerWindow.MainScreen, "Thông báo!"); MSPViewModel.ButtonCommandOV.IsSaveButtonRunning = false; return; } tblSupplier supplier = new tblSupplier(); supplier.SupplierID = MSPViewModel.SupplierInfo.SupplierID; supplier.SupplierName = MSPViewModel.SupplierName; supplier.Phone = MSPViewModel.Phone; supplier.Email = MSPViewModel.Email; supplier.Address = MSPViewModel.Address; supplier.SupplierDescription = MSPViewModel.Description; supplier.IsActive = true; _sqlCmdObserver = new SQLQueryCustodian(SQLQueryCallback); DbManager.Instance.ExecuteQueryAsync(SQLCommandKey.MODIFY_SUPPLIER_CMD_KEY, PharmacyDefinitions.MODIFY_SUPPLIER_DELAY_TIME, _sqlCmdObserver, supplier); return; }
private SQLQueryResult ModifySupplier(PharmacyDBContext appDBContext, object[] paramaters) { tblSupplier supplier = paramaters[0] as tblSupplier; SQLQueryResult result = new SQLQueryResult(null, MessageQueryResult.Non); try { var item = appDBContext.tblSuppliers.Where(o => o.SupplierID == supplier.SupplierID).FirstOrDefault(); item.SupplierName = supplier.SupplierName; item.Phone = supplier.Phone; item.Email = supplier.Email; item.Address = supplier.Address; item.SupplierDescription = supplier.SupplierDescription; item.IsActive = true; appDBContext.SaveChanges(); result = new SQLQueryResult(null, MessageQueryResult.Done); } catch (DbEntityValidationException e) { HandleDbEntityValidationException(e); result = new SQLQueryResult(null, MessageQueryResult.Aborted); } catch (Exception e) { App.Current.ShowApplicationMessageBox(e.Message); result = new SQLQueryResult(null, MessageQueryResult.Aborted); } return(result); }
private bool CheckResetAllWhenSupplierChanged(tblSupplier newValue) { if (LstWarehouseImportDetail.Count > 0 && _selectedSupplier != newValue) { var result = App.Current.ShowApplicationMessageBox("Thay đổi nhà cung cấp sẽ xóa toàn bộ dữ liệu nhập kho trong danh sách bên dưới.\nBạn có muốn tiếp tục?", HPSolutionCCDevPackage.netFramework.AnubisMessageBoxType.YesNo, HPSolutionCCDevPackage.netFramework.AnubisMessageImage.Question, OwnerWindow.MainScreen, "Cảnh báo!"); if (result == HPSolutionCCDevPackage.netFramework.AnubisMessgaeResult.ResultYes) { InitImportDetail(); return(true); } else { return(false); } } if (LstMedicine != null) { InitImportDetail(); } return(true); }
public async Task <CompanyCreateModel> UpdateCompany(CompanyCreateModel data) { try { CompanyCreateModel model = null; switch (data.companyType) { case "MSP": tblMSPDetail dataMSP = await Task.Run(() => ManageMSP.UpdateMSP(data.ConvertTotblMSPDetail())); model = dataMSP.ConvertTocompany(); break; case "Customer": tblCustomer dataCustomer = await Task.Run(() => ManageCustomer.UpdateCustomer(data.ConvertTotblCustomer())); model = dataCustomer.ConvertTocompany(); break; case "Supplier": tblSupplier dataSupplier = await Task.Run(() => ManageSupplier.UpdateSupplier(data.ConvertTotblSupplier())); model = dataSupplier.ConvertTocompany(); break; } return(model); } catch (Exception) { throw; } }
private void UpdateModifyData() { SupplierInfo = MSW_DataFlowHost.Current.CurrentModifiedSupplier; SupplierName = SupplierInfo.SupplierName; Phone = SupplierInfo.Phone; Email = SupplierInfo.Email; Address = SupplierInfo.Address; Description = SupplierInfo.SupplierDescription; }
public async Task <IActionResult> SaveSupplier([FromBody] tblSupplier tblSupplier) { if (!ModelState.IsValid) { return(await Task.FromResult(BadRequest(ModelState))); } return(Ok(await _service.SaveSupplier(tblSupplier))); }
public Supplier GetSupplierFromId(int suplierId) { tblSupplier sup = (from s in dc.tblSuppliers where s.supplierId == suplierId select s).FirstOrDefault(); Supplier supplier = GetCorrespondingSupplierFromtblSupplier(sup); return(supplier); }
private Supplier GetCorrespondingSupplierFromtblSupplier(tblSupplier sup) { return(new Supplier { supplierId = sup.supplierId, supplierName = sup.supplierName, supplierStatus = sup.supplierStatus, supplierContactNumber = sup.supplierContactNo, supplierAddress = sup.supplierAddress }); }
public string Check_Supplier(string code) { string jsonstring = string.Empty; tblSupplier sup = _supplierrepo.Get_SupplierbyCode(code); if (sup != null) { jsonstring = new JavaScriptSerializer().Serialize(sup); } return(jsonstring); }
private void GetCorrespondingtblSupplierFromSupplier(ref tblSupplier sup, Supplier _SupplierTobeEdited) { //return new tblSupplier //{ sup.supplierId = (int)_SupplierTobeEdited.supplierId; sup.supplierName = _SupplierTobeEdited.supplierName; sup.supplierStatus = _SupplierTobeEdited.supplierStatus; sup.supplierContactNo = _SupplierTobeEdited.supplierContactNumber; sup.supplierAddress = _SupplierTobeEdited.supplierAddress; //}; }
public bool Add_Supplier(tblSupplier sup) { bool status = false; if (sup != null) { db.tblSuppliers.InsertOnSubmit(sup); db.SubmitChanges(); status = true; } return(status); }
public void UpdateSupplierDetails(Supplier _SupplierTobeEdited) { //tblSupplier updated = GetCorrespondingtblSupplierFromSupplier(_SupplierTobeEdited); tblSupplier toBeUpdated = (from s in dc.tblSuppliers where s.supplierId == _SupplierTobeEdited.supplierId select s).FirstOrDefault(); GetCorrespondingtblSupplierFromSupplier(ref toBeUpdated, _SupplierTobeEdited); dc.SubmitChanges(); }
//Delete:Supplier By Id public bool Delete_SupplierById(int id) { bool status = false; tblSupplier sup = db.tblSuppliers.FirstOrDefault(x => x.Id == id && x.IsDeleted == false); if (sup != null) { sup.IsDeleted = true; db.SubmitChanges(); status = true; } return(status); }
public void AddSupplier(Supplier s) { try { tblSupplier tblSupplierObj = new tblSupplier(); getTableSupplierEquivalentFromSupplierEntity(ref tblSupplierObj, s); dc.tblSuppliers.InsertOnSubmit(tblSupplierObj); dc.SubmitChanges(); } catch (Exception ex) { throw ex; } }
public int AddNewSupplier(SupplierDetails sd) { tblSupplier ts = new tblSupplier(); ts.SupplierNo = sd.SupplierNo; ts.S_Name = sd.S_Name; ts.Address = sd.Address; ts.City = sd.City; ts.Email = sd.Email; ts.ContactNo = sd.ContactNo; ts.Photo = sd.Photo; _db.tblSuppliers.Add(ts); return(_db.SaveChanges()); }
private void getTableSupplierEquivalentFromSupplierEntity(ref tblSupplier tblSupplierObj, Supplier s) { try { tblSupplierObj.supplierName = s.supplierName; tblSupplierObj.supplierStatus = s.supplierStatus; tblSupplierObj.supplierContactNo = s.supplierContactNumber; tblSupplierObj.supplierAddress = s.supplierAddress; } catch (Exception ex) { throw ex; } }
public int UpdateSupplier(SupplierDetails sd) { tblSupplier ts = _db.tblSuppliers.Where(s => s.S_ID == sd.S_ID).FirstOrDefault(); ts.S_ID = sd.S_ID; ts.SupplierNo = sd.SupplierNo; ts.S_Name = sd.S_Name; ts.Address = sd.Address; ts.City = sd.City; ts.Email = sd.Email; ts.ContactNo = sd.ContactNo; ts.Photo = sd.Photo; return(_db.SaveChanges()); }
public async Task <string> AddUpdateSupplier(SupplierDomainModel supplier) { string status = ""; int sup_id = 0; if (supplier.sup_id > 0) { tblSupplier supplierToUpdate = await supplierRepository.SingleOrDefault(s => s.sup_id == supplier.sup_id); if (supplierToUpdate != null) { supplierToUpdate.name = supplier.name; supplierToUpdate.contact = supplier.contact; supplierToUpdate.company = supplier.company; supplierToUpdate.date = supplier.date; await supplierRepository.Update(supplierToUpdate); status = "updated"; } } else { tblSupplier supplierToAdd = new tblSupplier(); supplierToAdd.name = supplier.name; supplierToAdd.contact = supplier.contact; supplierToAdd.company = supplier.company; supplierToAdd.date = DateTime.Now; await supplierRepository.Insert(supplierToAdd); using (abuhamzapetstoreEntities db = new abuhamzapetstoreEntities()) { try { sup_id = (from c in db.tblSuppliers orderby c.sup_id descending select c.sup_id).Take(1).SingleOrDefault(); var result = db.stpOpenAccountWithMapping(sup_id, 1, 2, supplier.name); } catch (Exception ex) { status = ex.Message; } } status = "added"; } return(status); }
//Add New Supplier private void AddSupplier() { tblSupplier supplier = repo.Get_SupplierbyCode(txtcode.Text.Trim()); if (supplier != null) { ClientScript.RegisterStartupScript(this.GetType(), "toastr", "toastr.error('Same code already exist,please try again');", true); } else { if (db.tblSuppliers.FirstOrDefault(x => x.Name == txtName.Text.Trim() && x.IsDeleted == false) != null) { if (Session["WarningShow"] == null) { Session["WarningShow"] = "1"; ClientScript.RegisterStartupScript(this.GetType(), "toastr", "toastr.warning('Same name already exist. Click on save again to save record.');", true); } } if (Session["WarningShow"] == "1") { Session["WarningShow"] = "2"; } else { tblSupplier tblSupplier = new tblSupplier(); tblSupplier.Code = txtcode.Text.ToString(); tblSupplier.Name = txtName.Text.ToString(); tblSupplier.Address1 = txtaddress1.Text.ToString(); tblSupplier.Address2 = txtaddress2.Text.ToString(); tblSupplier.City = txtcity.Text.ToString(); tblSupplier.State = txtstate.Text.ToString(); tblSupplier.Country = txtcountry.Text.ToString(); tblSupplier.GSTNo = txtgstno.Text.ToString(); tblSupplier.PanNo = txtpanno.Text.ToString(); tblSupplier.ContactPerson = txtperson.Text.ToString(); tblSupplier.ContactMobile = txtmobile.Text.ToString(); tblSupplier.ContactEMail = txtemail.Text.ToString(); tblSupplier.IsDeleted = false; if (repo.Add_Supplier(tblSupplier)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('Supplier Record Saved Successfully')", true); HtmlMeta meta = new HtmlMeta(); meta.HttpEquiv = "Refresh"; meta.Content = "1;url=AddEdit.aspx"; this.Page.Controls.Add(meta); } } } }
public JsonResult UpdateProduct(tblSupplier model) { var service = new UpdateServices(); var res = service.SaveChangesSupplier(model); if (res) { return(Json(new { success = true })); } else { return(Json(new { success = false })); } }
private Supplier GetCorrespondingSupplierFromtblSupplier(tblSupplier sup) { return new Supplier { supplierId = sup.supplierId, supplierName = sup.supplierName, supplierStatus = sup.supplierStatus, supplierContactNumber = sup.supplierContactNo, supplierAddress = sup.supplierAddress }; }