public vendors get_sample_vendor() { vendors vendor_tester = new vendors(); vendor_tester.id = 0; vendor_tester.v_code = "QUCAST"; vendor_tester.business_name = "QUALITY CASTINGS"; vendor_tester.address_1 = "1908 MACARTHUR RD"; vendor_tester.address_2 = ""; vendor_tester.city_state_zip = "WAUKESHA WI 53188"; vendor_tester.fax_number = "414-475-6539"; vendor_tester.terms = ""; vendor_tester.order_contact = "RANDY HARRINGTON"; vendor_tester.order_email = "*****@*****.**"; vendor_tester.order_email_cc = "262-442-7565"; vendor_tester.order_phone = ""; vendor_tester.account_contact = ""; vendor_tester.account_email = ""; vendor_tester.account_phone = ""; vendor_tester.quality_contact = "test quality contact"; vendor_tester.quality_email = ""; vendor_tester.quality_phone = ""; vendor_tester.shipping_contact = ""; vendor_tester.shipping_email = ""; vendor_tester.shipping_phone = "test shipping phone"; return(vendor_tester); }
public string DeleteVendors(int id) { string rpta; vendors vendor = new vendors(); try { using (var ctx = new transshipEntities()) { vendor = ctx.vendors.FirstOrDefault(x => x.vendorId == id); if (vendor != null) { ctx.Entry(vendor).State = EntityState.Deleted; ctx.SaveChanges(); rpta = "ok"; } else { rpta = "fail"; } } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } return(rpta); }
public HttpResponseMessage UploadLogo() { var filePath = "~/Vendors/"; vendors vendor = new vendors(); vendors vend; BOVendors vendors = new BOVendors(); var logo = HttpContext.Current.Request.Files.AllKeys.Any(); //get paramaetes shipment files var vendorId = HttpContext.Current.Request.Params["model.vendorId"]; try { if (HttpContext.Current.Request.Files.AllKeys.Any()) { // Get the uploaded image from the Files collection var httpPostedFile = HttpContext.Current.Request.Files["UploadLogo"]; if (httpPostedFile != null) { var file_name = httpPostedFile.FileName; // Get the complete file path string fileSave = DateTime.Now.ToString("yyyyMMddHHmmss") + file_name; // if the directory doesn't exist - create it. if (!Directory.Exists(HttpContext.Current.Server.MapPath(filePath + "/" + vendorId))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath(filePath + "/" + vendorId)); string path = filePath + "/" + vendorId + "/" + fileSave; httpPostedFile.SaveAs(HttpContext.Current.Server.MapPath(path)); } else { string path = filePath + "/" + vendorId + "/" + fileSave; httpPostedFile.SaveAs(HttpContext.Current.Server.MapPath(path)); } vendor.logo = fileSave; } //map de parametes to model shipment attachment vendor.vendorId = Convert.ToDecimal(vendorId); } vendor.vendorId = Convert.ToDecimal(vendorId); vend = vendors.getVendorById(Convert.ToInt32(vendorId)); vend.logo = vendor.logo; vend = vendors.UpdateVendors(vend); return(Request.CreateResponse(HttpStatusCode.OK, vend)); } catch (Exception e) { ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to update Profile - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje)); } }
public HttpResponseMessage Put(vendors model) { try { BOVendors vendors = new BOVendors(); vendors coun; coun = vendors.UpdateVendors(model); return(Request.CreateResponse(HttpStatusCode.OK, coun)); } catch (Exception e) { ErrorMessage message = new ErrorMessage("2.1", "Exception to update vendors - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, message)); } }
public HttpResponseMessage GetVendorById(int vendorId) { try { BOVendors vendors = new BOVendors(); var vendor = new vendors(); vendor = vendors.getVendorById(vendorId); return(Request.CreateResponse(HttpStatusCode.OK, vendor)); } catch (Exception e) { ErrorMessage message = new ErrorMessage("2.1", "Exception to get vendors - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, message)); } }
public vendors getVendorById(int vendorId) { var vendor = new vendors(); try { using (var ctx = new transshipEntities()) { ctx.Configuration.LazyLoadingEnabled = false; vendor = ctx.vendors.Where(x => x.vendorId == vendorId).SingleOrDefault(); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } return(vendor); }
public vendors SaveVendors(vendors model) { var vendor = new vendors(); try { using (var ctx = new transshipEntities()) { vendor = ctx.vendors.Add(model); ctx.SaveChanges(); return(vendor); } }catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public List <vendors> rafRead(string path) { path = @"C:\INVEN\NVEND.DAT"; vendors a_vendor = new vendors(); List <vendors> returnData = new List <vendors>(); List <string> data = new List <string>(); List <int> fields = new List <int> { 6, 35, 24, 24, 30, 20, 4, 30, 45, 45, 20, 30, 45, 20, 30, 45, 20, 30, 45, 20 }; using (FileStream _fs = File.Open(path, FileMode.Open)) { byte[] b = new byte[574]; int position = 0; UTF8Encoding t = new UTF8Encoding(true); while (_fs.Read(b, 0, b.Length) > 0) { int ii = 0; position = 0; a_vendor = new vendors(); string xRaw = b[0].ToString(); string x = t.GetString(b.Skip(4).ToArray().Take(570).ToArray()); a_vendor.id = int.Parse(xRaw); for (int i = 0; i < 20; i++) { if (i == 20) { a_vendor = _switch.vendorSwitch(ii + 1, x.Substring(position, (x.Length - position)).Trim(), a_vendor); // values.Add(x.Substring(position, (x.Length - position)).Trim()); } else { a_vendor = _switch.vendorSwitch(ii + 1, x.TrimStart().Substring(position, fields[i]).Trim(), a_vendor); // values.Add(x.TrimStart().Substring(position, i).Trim()); } position += fields[i]; ii++; } returnData.Add(a_vendor); } } return(returnData); }
public IActionResult Create(vendors vendor) { if (HttpContext.Session.GetString("accRole").Equals("Admin")) { try { var result = db.vendors.FirstOrDefault(item => item.Vendor_id.Equals(vendor.Vendor_id)); var address = db.vendors.FirstOrDefault(item => item.Vendor_address.Equals(vendor.Vendor_address)); if (result == null) { if (address == null) { if (ModelState.IsValid) { db.vendors.Add(vendor); db.SaveChanges(); return(RedirectToAction("Index", "Vendors")); } else { ViewBag.Msg = "Model State is invalid!"; } } else { ViewBag.Msg = "This vendor address has already existed!!"; } } else { ViewBag.Msg = "This vendor has already existed!"; } return(View(@"~/Views/Admin/vendors/Create.cshtml")); } catch (Exception ex) { ModelState.AddModelError("Error: ", ex.Message); } } return(View(@"~/Views/Admin/ErrorPemission.cshtml")); }
public vendors UpdateVendors(vendors model) { vendors vendor = new vendors(); vendor = model; try { using (var ctx = new transshipEntities()) { ctx.Entry(vendor).State = EntityState.Modified; ctx.SaveChanges(); return(vendor); } }catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public void update_vendor(/*vendors vendor*/) { SqlCommandBuilder scb = new SqlCommandBuilder(); sample_data sampledata = new sample_data(); vendors vendor = sampledata.get_sample_vendor(); //select the vendor being used sql_conn.ConnectionString = _db_config.inven_general_conn; DataSet ds = new DataSet(); sql_conn.Open(); SqlDataAdapter sda1 = new SqlDataAdapter("SELECT TOP(1) * FROM vendor WHERE id = " + vendor.id, sql_conn); sda1.Fill(ds, "vendor"); scb = new SqlCommandBuilder(sda1); //((System.Data.DataTable)(new System.Collections.ArrayList.ArrayListDebugView(ds.Tables.List).Items[0])).Columns.List if (ds.Tables["vendor"].Rows.Count == 1) { object[] drd = ds.Tables["vendor"].Rows[0].ItemArray; for (int i = 1; i <= drd.Count(); i++) { vendor = _switch.vendorSwitch(i, drd[i].ToString(), vendor); } SqlCommand update = scb.GetUpdateCommand(true); foreach (SqlParameter param in update.Parameters) { if (param.SourceColumn.ToString() == "id") { continue; } else { param.Value = _switch.vendorSqlSwitch(param.SourceColumn, vendor); } } update.ExecuteNonQuery(); } sql_conn.Close(); }
public vendors UpdateVendors(vendors vendors) { return(vendor.UpdateVendors(vendors)); }
public vendors SaveVendors(vendors vendors) { return(vendor.SaveVendors(vendors)); }
public void create_vendor(vendors vendor) { }
public void query_vendor(vendors vendor) { }
public void delete_vendor(vendors vendor) { }