public ActionResult CreateSite(VendorSiteModel model) { if (ModelState.IsValid) { try { VendorModel vendor = VendorHelper.GetSingle(model.VendorId.ToString()); if ((model.StartDate >= vendor.StartDate && model.EndDate <= vendor.EndDate) || (model.StartDate == null && vendor.StartDate == null || model.EndDate == null && vendor.EndDate == null)) { VendorHelper.Save(model); return(RedirectToAction("ListSites", new { Id = model.VendorId })); } else { ModelState.AddModelError("Error", "Site Dates must be within the range of Vendor Dates."); } } catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); } //VendorHelper.Save(model); //return RedirectToAction("ListSites", new { Id = model.VendorId }); } return(View(model)); }
private object[] Take(VendorSiteModel model) { return(new object[] { "@vendor_site_id", model.VendorSiteId, "@vendor_id", model.VendorId, "@last_update_date", model.LastUpdateDate, "@last_updated_by", model.LastUpdatedBy, "@creation_date", model.CreationDate, "@created_by", model.CreatedBy, "@pay_site_flag", model.PaySiteFlag, "@address_line1", model.AddressLine1, "@address_line2", model.AddressLine2, "@address_line3", model.AddressLine3, "@city", model.City, "@state", model.State, "@province", model.Province, "@zip", model.Zip, "@country", model.Country, "@phone1", model.Phone1, "@phone2", model.Phone2, "@fax1", model.Fax1, "@fax2", model.Fax2, "@ship_to_location_id", model.ShipToLocationId, "@bill_to_location_id", model.BillToLocationId, "@vat_code", model.VatCode, "@terms_id", model.TermsId, "@invoice_currency_code", model.InvoiceCurrencyCode, "@vat_registration_num", model.VatRegistrationNum }); }
public void Delete(VendorSiteModel model) { string sql = @"DELETE FROM ap_supplier_sites_all WHERE vendor_site_id = @vendor_site_id"; object[] parms = { "@vendor_site_id", model.VendorSiteId }; db.Update(sql, parms); }
public void Update(VendorSiteModel model) { string sql = @"UPDATE ap_supplier_sites_all SET vendor_id = @vendor_id ,last_update_date = @last_update_date ,last_updated_by = @last_updated_by ,pay_site_flag = @pay_site_flag ,address_line1 = @address_line1 ,address_line2 = @address_line2 ,address_line3 = @address_line3 ,city = @city ,state = @state ,province = @province ,zip = @zip ,country = @country ,phone1 = @phone1 ,phone2 = @phone2 ,fax1 = @fax1 ,fax2 = @fax2 ,ship_to_location_id = @ship_to_location_id ,bill_to_location_id = @bill_to_location_id ,vat_code = @vat_code ,terms_id = @terms_id ,invoice_currency_code = @invoice_currency_code ,vat_registration_num = @vat_registration_num WHERE vendor_site_id = @vendor_site_id"; db.Update(sql, Take(model)); }
private static VendorSite GetEntityByModel(VendorSiteModel model) { if (model == null) { return(null); } VendorSite entity = new VendorSite(); entity.Id = model.Id; entity.Name = model.Name; entity.Address = model.Address; entity.CodeCombinationId = model.CodeCombinationId; entity.Contact = model.Contact; if (model.Id == 0) { entity.CreateBy = AuthenticationHelper.UserId; entity.CreateDate = DateTime.Now; } else { entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; } entity.EndDate = model.EndDate; entity.StartDate = model.StartDate; entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; entity.VendorId = model.VendorId; return(entity); }
public static long Save(VendorSiteModel model) { VendorSite entity = GetEntityByModel(model); return(model.Id > 0 ? service.Update(entity) : service.Insert(entity)); }
public int Insert(VendorSiteModel model) { string sql = @"INSERT INTO ap_supplier_sites_all (vendor_id ,last_update_date ,last_updated_by ,creation_date ,created_by ,pay_site_flag ,address_line1 ,address_line2 ,address_line3 ,city ,state ,province ,zip ,country ,phone1 ,phone2 ,fax1 ,fax2 ,ship_to_location_id ,bill_to_location_id ,vat_code ,terms_id ,invoice_currency_code ,vat_registration_num) VALUES (@vendor_id ,@last_update_date ,@last_updated_by ,@creation_date ,@created_by ,@pay_site_flag ,@address_line1 ,@address_line2 ,@address_line3 ,@city ,@state ,@province ,@zip ,@country ,@phone1 ,@phone2 ,@fax1 ,@fax2 ,@ship_to_location_id ,@bill_to_location_id ,@vat_code ,@terms_id ,@invoice_currency_code ,@vat_registration_num)"; return(db.Insert(sql, Take(model))); }
public ActionResult Edit(string id, long periodId) { PayableInvoiceModel model = PayableInvoiceHelper.GetInvoice(id); SessionHelper.Calendar = CalendarHelper.GetCalendar(PayablePeriodHelper.GetPayablePeriod(periodId.ToString()).CalendarId.ToString()); model.InvoiceDetail = PayableInvoiceHelper.GetInvoiceDetail(id); model.SOBId = SessionHelper.SOBId; model.PeriodId = periodId; model.Periods = PayablePeriodHelper.GetPeriodList(SessionHelper.SOBId); VendorModel vendors = VendorHelper.GetSingle(model.VendorId.ToString()); VendorSiteModel vendorSites = VendorHelper.GetSingle(model.VendorSiteId); InvoiceTypeModel invoiceTypes = InvoiceTypeHelper.GetInvoiceType(model.InvoiceTypeId.ToString()); ///TODO: Plz do the code audit. model.Vendors = new List <SelectListItem>(); model.Vendors.Add(new SelectListItem { Value = vendors.Id.ToString(), Text = vendors.Name }); model.VendorSites = new List <SelectListItem>(); model.VendorSites.Add(new SelectListItem { Value = vendorSites.Id.ToString(), Text = vendorSites.Name }); model.WHTaxes = new List <SelectListItem>(); if (model.WHTaxId != null) { WithholdingModel withHoldingTaxes = WithholdingHelper.GetWithholding(model.WHTaxId.ToString()); model.WHTaxes.Add(new SelectListItem { Value = withHoldingTaxes.Id.ToString(), Text = withHoldingTaxes.Description }); } model.InvoiceTypes = new List <SelectListItem>(); model.InvoiceTypes.Add(new SelectListItem { Value = invoiceTypes.Id.ToString(), Text = invoiceTypes.Description }); SessionHelper.PayableInvoice = model; return(View(model)); }
public ActionResult CreateSite(long id) { ViewBag.VendorName = VendorHelper.GetSingle(id.ToString()).Name; VendorSiteModel model = new VendorSiteModel(id); model.CodeCombination = codeCombinationService.GetAllCodeCombinitionView(AuthenticationHelper.CompanyId.Value) .Select(x => new SelectListItem { Text = x.CodeCombinitionCode, Value = x.Id.ToString() }).ToList(); //model.TaxCode = taxService.GetAll(AuthenticationHelper.CompanyId.value) // .Select(x => new SelectListItem // { // Text = x.TaxName, // Value = x.Id.ToString() // }).ToList(); return(View(model)); }