private void ToolStripButtonsave_Click(object sender, EventArgs e) { using (AccetManagementEntities db = new AccetManagementEntities()) { VENDOR vENDOR = new VENDOR { CONTACTNAME = txtContactName.Text, COUNTRY = txtCountry.Text, EMAIL = txtEmail.Text, PHONENO = txtphoneNumber.Text, POSTALADDRESS = txtAdress.Text, TOWN = txtTown.Text, VENDORNAME = txtVendorName.Text, VENDORNO = txtVendorNumber.Text, WEBSITE = txtWebsite.Text }; db.VENDORs.Add(vENDOR); db.SaveChanges(); this.Close(); MessageBox.Show("Saved Successfully to Database."); Application.Restart();; } }
public ActionResult DeleteConfirmed(string id) { VENDOR vENDOR = db.VENDORs.Find(id); db.VENDORs.Remove(vENDOR); db.SaveChanges(); return(RedirectToAction("Index")); }
private void ToolStripButtonDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to delete this record?", "DELETE VENDOR?", MessageBoxButtons.YesNo) == DialogResult.Yes) { var vendNo = Convert.ToString(this.dgvVendor.CurrentRow.Cells[1].Value); using (AccetManagementEntities db = new AccetManagementEntities()) { var getvendorFromDb = db.FINANCEs.Where(x => x.VENDORNO == vendNo).Select(x => x.VENDORNO).FirstOrDefault(); if (getvendorFromDb == null) { int rows = dgvVendor.RowCount; for (int i = rows - 1; i >= 0; i--) { if (dgvVendor.Rows[i].Selected) { VENDOR iVendor = new VENDOR { VENDORNO = vendNo }; iVendor = db.VENDORs.Where(x => x.VENDORNO == iVendor.VENDORNO).FirstOrDefault(); var entry = db.Entry(iVendor); if (entry.State == EntityState.Unchanged) { db.VENDORs.Attach(iVendor); db.VENDORs.Remove(iVendor); db.SaveChanges(); LoadGrid(); if (dgvVendor.CurrentRow == null) { MessageBox.Show("All Items deleted successfully"); } else { dgvVendor.Rows[0].Selected = false; } } //db.VIEWALLASSETS.Remove(dgvAllAssets.Rows[i].DataBoundItem as VIEWALLASSET); //vIEWALLASSETBindingSource.RemoveAt(dgvAllAssets.Rows[i].Index); } } } else { MessageBox.Show("Vendor is currently attached to an Asset"); } } } }
public ActionResult Edit([Bind(Include = "VendorID,VendorName,VendorAddress")] VENDOR vENDOR) { if (ModelState.IsValid) { db.Entry(vENDOR).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.VendorID = new SelectList(db.VENDORs, "VendorID", "MaterialID", vENDOR.VendorID); return(View(vENDOR)); }
// GET: VENDORs //public ActionResult Index() //{ // var vENDORs = db.VENDORs.Include(v => v.SUPPLy); // return View(vENDORs.ToList()); //} // GET: VENDORs/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VENDOR vENDOR = db.VENDORs.Find(id); if (vENDOR == null) { return(HttpNotFound()); } return(View(vENDOR)); }
// GET: VENDORs/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VENDOR vENDOR = db.VENDORs.Find(id); if (vENDOR == null) { return(HttpNotFound()); } ViewBag.VendorID = new SelectList(db.VENDORs, "VendorID", "MaterialID", vENDOR.VendorID); return(View(vENDOR)); }
/// <summary> /// Performs the playback of actions in this module. /// </summary> /// <remarks>You should not call this method directly, instead pass the module /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method /// that will in turn invoke this method.</remarks> void ITestModule.Run() { Mouse.DefaultMoveTime = 300; Keyboard.DefaultKeyPressTime = 100; Delay.SpeedFactor = 1.0; // create record to hold vendor data VENDOR vendor = new VENDOR(); vendor.name = "vendor" + StringFunctions.RandStr("X(8)"); // call create method from class to add customer PayablesLedger._SA_Create(vendor); PayablesLedger._SA_Close(); this.varVendor = vendor.name; }
public bool Rec_Vendor(Survey _surv) { int surveyID = Convert.ToInt32(_surv.S_ID); int Q_ID = Convert.ToInt32(_surv.ID); using (EventrixDBDataContext db = new EventrixDBDataContext()) { try { int _query = (from res in db.VENDORs where res.S_Id.Equals(surveyID) select res).Count(); if (_query == 0) //Create New Answer { VENDOR toinsert = new VENDOR(); toinsert.S_Id = _surv.S_ID; toinsert.Very_Dissatisfied = _surv.veryDissatisfied; toinsert.Dissatisfied = _surv.Dissatisfied; toinsert.Neutral = _surv.Neutral; toinsert.Very_Satisfied = _surv.VerySatisfied; toinsert.Satisfied = _surv.Satisfied; db.VENDORs.InsertOnSubmit(toinsert); db.SubmitChanges(); return(true); } else //Update Record { VENDOR query = (from res in db.VENDORs where res.S_Id.Equals(surveyID) select res).First(); query.Very_Dissatisfied += _surv.veryDissatisfied; query.Dissatisfied += _surv.Dissatisfied; query.Neutral += _surv.Neutral; query.Satisfied += _surv.Satisfied; query.Very_Satisfied += _surv.VerySatisfied; db.SubmitChanges(); return(true); } } catch (Exception) { return(false); } }; }
public ActionResult Create([Bind(Include = "VendorID,VendorName,VendorAddress")] VENDOR vENDOR) { if (ModelState.IsValid) { var count = db.VENDORs.ToList().Count(); if (count == 0) { vENDOR.VendorID = "01"; vENDOR.VendorAddress = "588 Riverside"; vENDOR.VendorName = "Jane Dine"; } else { vENDOR.VendorID = "0" + (count + 1).ToString(); } db.VENDORs.Add(vENDOR); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.VendorID = new SelectList(db.VENDORs, "VendorID", "MaterialID", vENDOR.VendorID); return(View(vENDOR)); }
/// <summary> /// Performs the playback of actions in this module. /// </summary> /// <remarks>You should not call this method directly, instead pass the module /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method /// that will in turn invoke this method.</remarks> void ITestModule.Run() { Mouse.DefaultMoveTime = 300; Keyboard.DefaultKeyPressTime = 100; Delay.SpeedFactor = 1.0; // Create a vendor VENDOR ven = new VENDOR(); if (this.varItem == "") { ven.name = "Vend" + StringFunctions.RandStr("X(8)"); PayablesLedger._SA_Create(ven); PayablesLedger._SA_Close(); } else { ven.name = this.varVendor; } // Create an item ITEM item = new ITEM(); item.ItemPrices.Add(new ITEM_PRICE("Canadian Dollars")); item.ItemPrices[0].priceList = "Regular"; item.ItemPrices[0].pricePerSellingUnit = Functions.RandCashAmount(); if (this.varItem == "") { item.invOrServNumber = StringFunctions.RandStr("A(9)"); InventoryServicesLedger._SA_Create(item); InventoryServicesLedger._SA_Close(); } else { item.invOrServNumber = this.varItem; } // Create an Invoice PURCHASE_INVOICE pi = new PURCHASE_INVOICE(); pi.Vendor = ven; ROW r = new ROW(); r.Item = item; r.quantityReceived = Functions.RandCashAmount(2); r.price = Functions.RandCashAmount(); pi.GridRows.Add(r); if (this.varPInvoice == "") { pi.transNumber = StringFunctions.RandStr("9(8)"); PurchasesJournal._SA_Create(pi); System.Threading.Thread.Sleep(2000); PurchasesJournal._SA_Close(); } else { pi.transNumber = this.varPInvoice; } // Adjust the invoice pi.GridRows[0].quantityReceived = Functions.RandCashAmount(2); PurchasesJournal._SA_Create(pi, true, true); PurchasesJournal._SA_Close(); }
partial void DeleteVENDOR(VENDOR instance);
partial void UpdateVENDOR(VENDOR instance);
partial void InsertVENDOR(VENDOR instance);
/// <summary> /// Performs the playback of actions in this module. /// </summary> /// <remarks>You should not call this method directly, instead pass the module /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method /// that will in turn invoke this method.</remarks> void ITestModule.Run() { Mouse.DefaultMoveTime = 300; Keyboard.DefaultKeyPressTime = 100; Delay.SpeedFactor = 1.0; string sT5018Summary = @"C:\Users\Public\Documents\Simply Accounting\2018\Data\Summary of Contract Payments.pdf";// @"C:\Users\_sabvt\Documents\Simply Accounting\DATA\Summary of Contract Payments.pdf"; string sInstallPath = Simply._SA_GetProgramPath(); string sDllPath = string.Format(@"{0}acPDFCreatorLib.Net.dll", sInstallPath); // Check Sage 50 pdf engine dll is installed before starting test case if (Functions.VerifyFileExists(sDllPath)) { // Remove existing pdf file Functions.RemoveExistingFile(sT5018Summary); // Create a T5018 vendor VENDOR tvendor = new VENDOR(); tvendor.name = StringFunctions.RandStr("A(9)"); tvendor.includeFilingT5018CheckBox = true; PayablesLedger._SA_Create(tvendor); PayablesLedger._SA_Close(); // Create an item ITEM item = new ITEM(); ITEM_PRICE itemPrice = new ITEM_PRICE(); itemPrice.currency = "Canadian Dollars"; itemPrice.priceList = "Regular"; itemPrice.pricePerSellingUnit = Functions.RandCashAmount(); item.ItemPrices.Add(itemPrice); if (this.varItem == "") { item.invOrServNumber = StringFunctions.RandStr("A(9)"); InventoryServicesLedger._SA_Create(item); InventoryServicesLedger._SA_Close(); } else { item.invOrServNumber = this.varItem; } // Create purchase invoice using T5018 vendor PURCHASE_INVOICE purInv = new PURCHASE_INVOICE(); purInv.Vendor = tvendor; purInv.transNumber = StringFunctions.RandStr("9(8)"); ROW firstRow = new ROW(); firstRow.Item.invOrServNumber = item.invOrServNumber; firstRow.quantityReceived = Functions.RandCashAmount(2); firstRow.price = Functions.RandCashAmount(); purInv.GridRows.Add(firstRow); PurchasesJournal._SA_Create(purInv); PurchasesJournal._SA_Close(); // Print T5018 summary to a file string sCraNumber = "403381601RZ0001"; Simply._Print_T5018Summary(sCraNumber); // Verify printed file if (!Functions.VerifyFileExists(sT5018Summary)) { Functions.Verify(false, true, "Printed T5018 form found"); } } else { Functions.Verify(false, true, "PDF engine dll file found"); } // Wait 5 seconds before moving on to next testcase Thread.Sleep(5000); }
static void Main(string[] args) { Console.WriteLine("This program will allow you to obtain product information about certain products or enter new products. "); //choose the db schema to connect to DataClasses1DataContext db = new DataClasses1DataContext(); //get user choice int choice = menu(); while (choice != 3) { if (choice == 1) { Console.WriteLine("\nYou have chosen to view product information for specific products:"); Console.WriteLine("\nplease enter the minimum price."); Double minPrice = Double.Parse(Console.ReadLine()); Console.WriteLine("Please enter the maximum price of the products you wish to see."); Double maxPrice = Double.Parse(Console.ReadLine()); var productsInRange = db.PRODUCTs.Where(P => P.P_PRICE.CompareTo(minPrice) >= 0 && P.P_PRICE.CompareTo(maxPrice) <= 0); foreach (var product in productsInRange) { Console.WriteLine("\nProduct Description: " + product.P_DESCRIPT + "\nPrice: " + product.P_PRICE + "\nVendor Name: " + (product.VENDOR?.V_NAME ?? "NO VENDOR")); } } else if (choice == 2) { Console.WriteLine("\nYou have chosen to enter a new product."); Console.WriteLine("Enter \"Y\" for yes to enter a new Vendor, or \"N\" for no to enter an existing Vendor Code of the new Product."); String reply = Console.ReadLine().ToUpper(); int vcode = 0; if (reply != "Y" && reply != "N") { Console.WriteLine("Invalid Entry. "); } else { if (reply == "Y") { VENDOR v = new VENDOR(); Console.WriteLine("Please enter the Vendor Code: (Code should be all numbers)"); vcode = Int32.Parse(Console.ReadLine()); v.V_CODE = vcode; //check if v_Code is already in use: while (db.VENDORs.Any(v2 => v2.V_CODE == v.V_CODE)) { Console.WriteLine("Vendor Code already in use. Please try again."); vcode = Int32.Parse(Console.ReadLine()); v.V_CODE = vcode; } Console.WriteLine("Please enter the vendor name"); v.V_NAME = Console.ReadLine(); Console.WriteLine("Please enter the Vendor Contact:"); v.V_CONTACT = Console.ReadLine(); Console.WriteLine("Please enter the Vendor Area Code:"); v.V_AREACODE = Console.ReadLine(); Console.WriteLine("Please enter the Vendor Phone:"); v.V_PHONE = Console.ReadLine(); Console.WriteLine("Please enter the Vendor State:"); v.V_STATE = Console.ReadLine(); Console.WriteLine("Please enter \'Y\' or \'N\' for Vendor Order Status:"); v.V_ORDER = Char.Parse(Console.ReadLine()); bool vendorEntered = false; while (!vendorEntered) { try { db.VENDORs.InsertOnSubmit(v); db.SubmitChanges(); Console.WriteLine("New Vendor Entered!"); vendorEntered = true; } catch (Exception e) { Console.WriteLine("Error. Unable to enter vendor"); } } } else if (reply == "N") { Console.WriteLine("Please enter the Vendor Code:"); vcode = Int32.Parse(Console.ReadLine()); //check if v_Code is valid while (!db.VENDORs.Any(v2 => v2.V_CODE == vcode)) { Console.WriteLine("Vendor Code is not valid. Please try again."); vcode = Int32.Parse(Console.ReadLine()); } } PRODUCT newProduct = new PRODUCT(); Console.WriteLine("\nPlease enter the Product Description:"); newProduct.P_DESCRIPT = Console.ReadLine(); Console.WriteLine("Please enter the Product Code:"); newProduct.P_CODE = Console.ReadLine(); //check if product code is already in use: while (db.PRODUCTs.Any(p => p.P_CODE == newProduct.P_CODE)) { Console.WriteLine("Product Code already in use. Please try again."); newProduct.P_CODE = Console.ReadLine(); } Console.WriteLine("Please enter the date the product came in:"); bool dateValid = false; while (!dateValid) { try { newProduct.P_INDATE = DateTime.Parse(Console.ReadLine()); dateValid = true; } catch (Exception e) { Console.WriteLine("Date entered was invalid. Please try again"); } } Console.WriteLine("Please enter the quantity on hand:"); newProduct.P_QOH = Int32.Parse(Console.ReadLine()); Console.WriteLine("Please enter the product minimum:"); newProduct.P_MIN = Int32.Parse(Console.ReadLine()); Console.WriteLine("Please enter the product price:"); newProduct.P_PRICE = Decimal.Parse(Console.ReadLine()); Console.WriteLine("Please enter the Product Discount :"); newProduct.P_DISCOUNT = Decimal.Parse(Console.ReadLine()); newProduct.V_CODE = vcode; try { db.PRODUCTs.InsertOnSubmit(newProduct); db.SubmitChanges(); Console.WriteLine("New product entered!"); } catch (Exception e) { Console.WriteLine("Error. Unable to enter product."); } } } else { Console.WriteLine("Invalid selection. Please try again."); } choice = menu(); } // System.Environment.Exit(1); Console.ReadKey(); }
static void Main(string[] args) { DataClasses1DataContext db = new DataClasses1DataContext(); int max; int min; //ask for max and min Console.WriteLine("What is the minimum price that you want to search for?"); min = int.Parse(Console.ReadLine()); Console.Write("What is the maximum price you want to search for?"); max = int.Parse(Console.ReadLine()); var prdcts = db.PRODUCTs.Where(p => p.P_PRICE > min && p.P_PRICE < max); Console.WriteLine($"These are the items priced between {min} and {max}"); //write products to the screen foreach (var products in prdcts) { Console.WriteLine($"P.Code {products.P_CODE}, Desc: {products.P_DESCRIPT}," + $" Price: {products.P_PRICE}, QOH:{products.P_QOH}, V_Code:{products.P_CODE}" + $", Vendor Name:{products.VENDOR.V_NAME}, Vendor Contact {products.VENDOR.V_PHONE}"); } //CREATE A NEW PRODUCT Console.WriteLine("Enter the new products name:"); String name = Console.ReadLine(); Console.WriteLine("Enter the new products description:"); String desc = Console.ReadLine(); Console.WriteLine("What date will the product be in stock?"); System.DateTime date = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Enter the new products price:"); Decimal price = decimal.Parse(Console.ReadLine()); Console.WriteLine("Enter the new products QOH:"); Decimal qoh = decimal.Parse(Console.ReadLine()); Console.WriteLine("What is the min of the product?"); Decimal minn = decimal.Parse(Console.ReadLine()); Console.WriteLine("Enter the new products discount:"); Decimal discount = decimal.Parse(Console.ReadLine()); Console.WriteLine("Enter the new products code"); String code = Console.ReadLine(); int vendorCode; VENDOR vendor = null; Console.WriteLine("Enter 1 to choose an exisiting vendor or enter 2 to add a new vendor"); int choice = int.Parse(Console.ReadLine()); if (choice == 1) { Console.WriteLine("What is the vendors code?"); vendorCode = int.Parse(Console.ReadLine()); //check if vendor does n fact exist while (!db.VENDORs.Any(v => v.V_CODE.Equals(vendorCode))) { ; } { Console.WriteLine("Sorry the Vendor code could not befound, please renenter the code"); vendorCode = int.Parse(Console.ReadLine()); } //assign the matching vender to variable vendor = db.VENDORs.Where(v => v.V_CODE == vendorCode).First(); } else { //create a new vendor Console.WriteLine("What is the new vendors code?"); vendorCode = int.Parse(Console.ReadLine()); Console.WriteLine("What is the name of the vendor?"); String vendorName = Console.ReadLine(); Console.WriteLine("Who is the contact at this vendor?"); String vendorContact = Console.ReadLine(); Console.WriteLine("What is the area code of the vendor?"); String vendorArea = Console.ReadLine(); Console.WriteLine("What is the phone number of the vendor?"); String vendorPhone = Console.ReadLine(); Console.WriteLine("What state is the vendor in?"); String vendorState = Console.ReadLine(); Console.WriteLine("Does this vendor accpet orders? (Enter Y or N)"); Char vendorOrders = char.Parse(Console.ReadLine()); vendor = new VENDOR { V_NAME = vendorName, V_CODE = vendorCode, V_AREACODE = vendorArea, V_PHONE = vendorPhone, V_STATE = vendorState, V_CONTACT = vendorContact, V_ORDER = vendorOrders }; //add to database db.VENDORs.InsertOnSubmit(vendor); db.SubmitChanges(); } //create new product PRODUCT pr = new PRODUCT { P_CODE = code, P_DESCRIPT = desc, P_PRICE = price, P_INDATE = date, P_QOH = qoh, P_MIN = minn, P_DISCOUNT = discount, }; pr.VENDOR = vendor; //add new product to database db.PRODUCTs.InsertOnSubmit(pr); db.SubmitChanges(); Console.WriteLine("The product has been added to the database"); Console.ReadKey(); }