public CreatePurchaseOrder(IdentityObject ident,Purchases.InventoryItem item) { InitializeComponent(); label_SubName.Text = "New Purchase Order"; _ident = ident; textBox_Role.Text = _ident.Role; if (_ident == null) _ident = new IdentityObject("111", "Johnson", "clerk", 1, 2); textBox_Employee.Text = _ident.UserID; textBox_AuthLevel.Text = _ident.ActionLevel.ToString(); FillSupplier(); comboBox1.SelectedIndex = item.Supplier; textBox_Supplier.Text = item.Supplier.ToString(); comboBox1_SelectedIndexChanged(this, null); _productID = item.ProductID.ToString(); //textBox_Comment.Text = "Product No:" + _productID + "(" + item.ProductName +")"; textBox_OnHand.Text = item.OnHand.ToString(); textBox_MinQuantity.Text = item.MinQuantity.ToString(); textBox_Quantity.Text = (item.MinQuantity - item.OnHand).ToString(); textBox_Price.Text = item.Cost.ToString(); textBox_ProductID.Text = item.InvID.ToString(); textBox_PO_ID2.Text = item.ProductName.ToString(); button_Preview.Visible = false; button_DataToText.Visible = false; button_ConvertToSql.Visible = false; NewPurchaseOrder(_ident); }
/// <summary> /// Update Purchases /// </summary> /// <param name="entity"></param> /// <returns>Message</returns> public async Task <string> UpdatePurchases(Purchases entity) { try { var result = await new PurchasesRepository(logger).Update(entity); return(result); } catch (Exception ex) { logger.Error(ex.Message); throw ex; } }
public ActionResult Create([Bind(Include = "PurchasesID,AlbumID,CustomerID,Rating")] Purchases purchases) { if (ModelState.IsValid) { db.Purchases.Add(purchases); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AlbumID = new SelectList(db.Albums, "AlbumID", "Artist", purchases.AlbumID); ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "LastName", purchases.CustomerID); return(View(purchases)); }
public async Task <bool> BuyAsync(Purchases purchases) { if (purchases == null) { throw new ArgumentNullException(); } await using var db = new GameCatalogContext(); await db.Purchaseses.AddAsync(purchases); await db.SaveChangesAsync(); return(true); }
public async Task<ActionResult> Create(Purchases data) { string result = string.Empty; try { result = await repo.InsertPurchases(data); } catch (Exception ex) { result = "Fail~" + ex.Message.ToString(); throw; } return Json(result, JsonRequestBehavior.AllowGet); }
// GET: /Purchase/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Purchases purchases = db.Purchases.Find(id); if (purchases == null) { return(HttpNotFound()); } return(View(purchases)); }
/* * Helpers */ private bool PurchasesAreEquivalent(Purchases pur1, Purchases pur2) { if (!pur1.Id().Equals(pur2.Id()) || !pur1.CustomerIp().Equals(pur2.CustomerIp()) || !pur1.MerchantRefNum().Equals(pur2.MerchantRefNum()) || !pur1.Status().Equals(pur2.Status()) || !ProfilesAreEquivalent(pur1.Profile(), pur2.Profile()) || !BillingDetailsAreEquivalent(pur1.BillingDetails(), pur2.BillingDetails())) { return(false); } return(true); }
public SupplierDetails(IUnitOfWork unitOfWork, int supplierId, DateTime?sDate, DateTime?eDate) { _SupplierId = supplierId; _db = unitOfWork; _sDate = sDate ?? new DateTime(1000, 1, 1); _eDate = eDate ?? new DateTime(3000, 1, 1); GetSupplierInfo(); GetPurchases(); GetDues(); DateToDateDue = Math.Round(Purchases.Sum(s => s.PurchaseDueAmount), 2); DateToDatePaid = Math.Round(Purchases.Sum(s => s.PurchasePaidAmount), 2); DateToDateSale = Math.Round(Purchases.Sum(s => s.PurchaseAmount), 2); DateToDateDiscount = Math.Round(Purchases.Sum(s => s.PurchaseDiscountAmount), 2); }
private void RefreshItems() { Purchases.Clear(); foreach (var item in SelectedClient.Purchases) { if (SelectedClient.Purchases == null) { NotifyClient("Veuillez vous connecter"); } Purchases.Add(item); } }
public async Task <ActionResult> Edit(Purchases data) { string result = string.Empty; try { result = await repo.UpdatePurchases(data); } catch (Exception ex) { throw; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Create([Bind("PurchaseId,PurchaseTicketDate,PurchaseAmount,Id,TicketId,DeliveryId")] Purchases purchases) { if (ModelState.IsValid) { _context.Add(purchases); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Id"] = new SelectList(_context.ApplicationUsers, "Id", "Id", purchases.Id); ViewData["DeliveryId"] = new SelectList(_context.Deliveries, "DeliveryId", "DeliveryType", purchases.DeliveryId); ViewData["TicketId"] = new SelectList(_context.Tickets, "TicketId", "TicketName", purchases.TicketId); return(View(purchases)); }
public ActionResult Delete(int?id) { if (id == null) { return(HttpNotFound()); } Purchases purch = db.Purchases.Find(id); if (purch == null) { return(HttpNotFound()); } return(View(purch)); }
private void GetInvoices(DateTime StartDate, DateTime EndDate, int InvoiceNumber = 0, Beverage bev = null) { if (InvoiceNumber < 1) { var data = Purchases.Join(Invoices, b => b.InvoiceId, a => a.InvoiceId, (a, b) => new { BeverageName = a.Beverage.Name, Quantity = a.Quantity, Metric = a.Metric, Rate = a.Rate, Amount = a.LineTotalAmount, InvoiceDate = b.Date, InvoiceNumber = b.InvoiceNumber, SupplierName = b.Supplier.SupplierName } ).Where(a => a.InvoiceDate.Date <= EndDate.Date && a.InvoiceDate.Date >= StartDate).ToList(); App.Current.Dispatcher.Invoke(() => { InvoiceRVIew = CollectionViewSource.GetDefaultView(data); InvoiceRVIew.GroupDescriptions.Add(new PropertyGroupDescription("InvoiceNumber")); }); } else { StartDatePurchase = DateTime.Today; EndDate = DateTime.Today; var data = Purchases.Join(Invoices, b => b.InvoiceId, a => a.InvoiceId, (a, b) => new { BeverageName = a.Beverage.Name, Quantity = a.Quantity, Metric = a.Metric, Rate = a.Rate, Amount = a.LineTotalAmount, InvoiceDate = b.Date, InvoiceNumber = b.InvoiceNumber, SupplierName = b.Supplier.SupplierName, Invoice = b } ).Where(a => a.InvoiceNumber == InvoiceNumber).ToList(); App.Current.Dispatcher.Invoke(() => { InvoiceRVIew = CollectionViewSource.GetDefaultView(data); InvoiceRVIew.GroupDescriptions.Add(new PropertyGroupDescription("InvoiceNumber")); }); } Task.Run(() => GetInfoPurchaseAsync(StartDate, EndDate, InvoiceNumber)); }
public string DeletePurchase(Purchases purchases) { var del = _context.Purchases.Find(purchases.PurchasesID); if (del != null) { _context.Purchases.Remove(del); _context.SaveChanges(); } else { return("Not Deleted"); } return("Success"); }
public async Task<JsonResult> Delete(string ids) { string result = string.Empty; string[] IdList = ids.Split('~'); Purchases vm = new Purchases(); try { result = await repo.IsDeletePurchases(IdList, vm); } catch (Exception ex) { throw; } return Json(result, JsonRequestBehavior.AllowGet); }
public int Save(Purchases purchases) { int idGenerated = 0; query = "INSERT INTO purchases (user_id,provider_id,purchase_total)VALUES (@userId,@providerId,@purchaseTotal)"; @params = new Dictionary <string, object> { { "@userId", purchases.UserId }, { "@providerId", purchases.ProviderId }, { "@purchaseTotal", purchases.PurchaseTotal } }; base.Execute(out idGenerated); Console.WriteLine("Purchase registred with ID: {0}", idGenerated); return(idGenerated); }
// GET: /Purchase/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Purchases purchases = db.Purchases.Find(id); if (purchases == null) { return(HttpNotFound()); } ViewBag.SupplierId = new SelectList(db.Suppliers, "SupplierId", "SupplierName", purchases.SupplierId); return(View(purchases)); }
public async Task <ActionResult> BuyCofirmation() { var user = Convert.ToInt32(Session["UserId"]); var not = db.Notifications.Where(u => u.NOT_U_Id == user && u.NOT_Leido == false); ViewBag.noti = not; var cart = db.Cart.Where(c => c.C_US_Id == user); var ud = db.UserData.Find(user); UserData usuario = new UserData() { US_Email = ud.US_Email }; //Remove items from shopping cart and add to User purchases foreach (var c in cart) { var photoUs = db.Photo.Find(c.C_PH_Id); usuario.Photo.Add(photoUs); Purchases pur = new Purchases(); try { pur.PUR_PH_Id = c.C_PH_Id; pur.PUR_US_Id = c.C_US_Id; pur.PUR_DatePurchase = DateTime.Now; pur.Photo = c.Photo; db.Purchases.Add(pur); } catch (Exception e) { Console.WriteLine(e); RedirectToAction("ErrorPage", "Error"); } DeleteItem(c.C_Id); addToNotifications(c.C_PH_Id, 2); } db.SaveChanges(); ActionResult x = await SendPhoto(usuario); return(View()); }
public ActionResult DeleteConfirmed(int?id) { if (id == null) { return(HttpNotFound()); } Purchases purch = db.Purchases.Find(id); if (purch == null) { return(HttpNotFound()); } db.Purchases.Remove(purch); db.SaveChanges(); return(RedirectToAction("Index")); }
// similar sort of idea to Browse.cs when opening that. See that file fior more detailed // commentary private void see_purchase(object sender, RoutedEventArgs e) { try { ItemPage next_nav = new ItemPage(); Purchases selected_id = (Purchases)purchase_table.SelectedItems[0]; next_nav.show_system_info((Int64)selected_id.ItemID); } catch (Exception Ex) { // Commented out data in here allows for an on the fly debugging mode. This would // have been better with the developer_mode variable but due to time constrains // this will have to do MessageBox.Show("You must have selected an item before proceeding!" /*Error: " + Ex + ". Actual Error Message: " + Ex.Message*/, "Alert!", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
public bool AddOrUpdatePurchases(Purchases purchases) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { _DBContext.Purchases.AddOrUpdate(purchases); _DBContext.SaveChanges(); return(true); } } catch (Exception e) { return(false); } }
public void AddPurchase(int price, IBonusCalcStrategy bonusCalculator) { if (price < 0) { throw new ArgumentException("Should not be negative", nameof(price)); } var purchase = new Purchase { CardId = Id, Price = price, Bonus = bonusCalculator.Calc(price) }; Purchases.Add(purchase); }
// GET: Purchase/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Purchases purchases = db.Purchases.Find(id); if (purchases == null) { return(HttpNotFound()); } ViewBag.AlbumID = new SelectList(db.Albums, "AlbumID", "Artist", purchases.AlbumID); ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "LastName", purchases.CustomerID); return(View(purchases)); }
public static void Main(string[] args) { try { /// ///@get List<Payments> /// Payments payments = new Payments(); string FileNamePayments = "Payments.json"; List <Payments> paymentsList = payments.ReadPaymentsFromFile(FileNamePayments); /// ///@get List<Prices> /// Prices prices = new Prices(); string FileNamePrices = "Prices.xml"; List <Prices> pricesList = prices.ReadPricesFromFile(FileNamePrices); /// ///@get List<Purchases> /// Purchases purchases = new Purchases(); string FileNamePurchases = "Purchases.dat"; List <Purchases> purchaseList = purchases.ReadPurchasesFromFile(FileNamePurchases); /// ///@get List<PaymentsNotMatched> /// PaymentsNotMatched paymentsNotMatched = new PaymentsNotMatched(); List <PaymentsNotMatched> paymentsNotMatchedList = paymentsNotMatched.ReadPaymentsNotMatchedList(paymentsList, purchaseList, pricesList); /// ///@write List<PaymentsNotMatched> /// paymentsNotMatched.WritePaymentsToFileJson(paymentsNotMatchedList); paymentsNotMatched.WritePaymentsToFileCsv(paymentsNotMatchedList); Console.WriteLine("Press one key to exit"); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("Ex:{0}", ex.Message); } }
public Purchases LastExistInvoice() { Purchases _Purchase = null; string query = "Select top 1 Invoice from Purchases order by Invoice desc"; var reader = _MainRepository.Reader(query, _MainRepository.ConnectionString()); if (reader.HasRows) { reader.Read(); _Purchase = new Purchases(); _Purchase.Invoice = (reader["Invoice"].ToString()); } reader.Close(); return(_Purchase); }
void SendAttribution() { Purchases purchases = GetComponent <Purchases>(); Purchases.AdjustData data = new Purchases.AdjustData(); data.adid = "test"; data.network = "network"; data.adgroup = "adgroup"; data.campaign = "campaign"; data.creative = "creative"; data.clickLabel = "clickLabel"; data.trackerName = "trackerName"; data.trackerToken = "trackerToken"; purchases.AddAttributionData(JsonUtility.ToJson(data), Purchases.AttributionNetwork.ADJUST); }
/// <summary> /// событие открытия окна с добавлением товара в корзину /// </summary> /// <param name="o"></param> private void OnAddCommandExecuted(object o) { Purchases pr = new Purchases(); pr.storage = new Storage(); pr.idstorage = SelectItemDataGrid.idStorage; if (purchases == null) { purchases = new List <Purchases>(); } if (purchases.Count <= 0) { pr.idPurchases = 1; } else { pr.idPurchases = purchases.Count + 1; } pr.storage.idStorage = SelectItemDataGrid.idStorage; double discover = 0; pr.idFirm = FindidFirm(out discover); pr.CurrentDiscountAmount = discover; if (pr.idFirm == 0) { return; } pr.FirmName = MainViewModel.SelectFirm; pr.storage.NameCategory = SelectItemDataGrid.NameCategory; pr.storage.Name = SelectItemDataGrid.Name; pr.storage.Price = SelectItemDataGrid.Price; pr.storage.UnitName = SelectItemDataGrid.UnitName; pr.storage.Description = SelectItemDataGrid.Description; new WindowAddPurchase(pr, SelectItemDataGrid.Count).ShowDialog(); if (pr != null && purchases != null) { if (!(pr.Count <= 0)) { purchases.Add(pr); } } }
public void ChangeQuantity(Item item, int quantity) { int index = Purchases.FindIndex(x => x.PurchaseItem.ItemId == item.Id); if (index == -1) { Console.WriteLine($"Item {item.Name} can't be found"); } else { if (quantity == 0) { int[] ids = { Purchases[index].PurchaseItem.Id }; if (PurchaseItemManager.Delete(ids, "Id")) { Purchases.RemoveAt(index); Console.WriteLine("Item remove completely."); } else { Console.WriteLine("Item can't be removed!"); } } else { using (TransactionScope scope = new TransactionScope()) { Purchases[index].PurchaseItem.Quantity = quantity; Purchases[index].PurchaseItem.SubTotal = quantity * item.Price; if (PurchaseItemManager.Update(Purchases[index].PurchaseItem)) { Console.WriteLine("Item quantity change successfully."); } else { Console.WriteLine("Item quantity can't be change."); return; } scope.Complete(); } } } }
public Purchases GetLastPurchaseId() { Purchases _Purchase = null; string query = "Select top 1 PurchaseId from Purchase order by PurchaseId desc"; var reader = _pharmaDb.Reader(query, _pharmaDb.ConnectionStrings()); if (reader.HasRows) { reader.Read(); _Purchase = new Purchases(); _Purchase.PurchaseId = (reader["PurchaseId"].ToString()); } reader.Close(); return(_Purchase); }
public void DeletePurchase(Purchases purchase) { // I don't think a delete is needed using (var cn = new SqlConnection(Settings.GetConnectionString())) { SqlCommand cmd = new SqlCommand("DeletePurchase", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@purchaseIdId", purchase.PurchaseId); cn.Open(); cmd.ExecuteNonQuery(); cn.Close(); } }
/// <summary> /// Delete Purchases /// </summary> /// <param name="Id"></param> /// <returns>Message</returns> public async Task <string> IsDeletePurchases(string[] IdList, Purchases entity) { string result = string.Empty; try { for (int i = 0; i < IdList.Length - 1; i++) { result = await new PurchasesRepository(logger).IsDelete(Convert.ToInt32(IdList[i]), entity); } } catch (Exception ex) { logger.Error(ex.Message); throw ex; } return(result); }
protected void LoadReceipts( Purchases.Criteria criteries ) { try{ this.lvReceipts.ListViewItemSorter = this.lvColumnSorter; this.lvReceipts.Items.Clear(); this.receipts.Rows.Clear(); System.Data.SqlClient.SqlCommand cmd = Purchases.Commands.Receipts( criteries ); cmd.Connection = this.cConnection; System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(cmd); sda.Fill( this.receipts ); string colname = "ReceiptID"; if( !this.receipts.Columns.Contains( colname ) ) this.receipts.Columns.Add(colname); //this.receipts.Columns[colname].AutoIncrement = true; //this.receipts.Columns[colname].AutoIncrementSeed = -1; //this.receipts.Columns[colname].AutoIncrementStep = -1; this.receipts.Columns[colname].DefaultValue = System.Guid.NewGuid(); this.CalculateTotal( true ); // this.receipts.Columns[colname].AutoIncrement = true; // this.receipts.Columns[colname].AutoIncrementSeed = (int)this.receipts.Rows[i - 1][colname] + 1; }catch (System.Data.SqlClient.SqlException ex){ this.tsslQueryResult.Text = ex.Message; }catch (System.Exception ex){ this.tsslQueryResult.Text = ex.Message; } return; }
public async Task<ActionResult> BuyCofirmation() { var user = Convert.ToInt32(Session["UserId"]); var not = db.Notifications.Where(u => u.NOT_U_Id == user && u.NOT_Leido == false); ViewBag.noti = not; var cart = db.Cart.Where(c => c.C_US_Id == user); var ud = db.UserData.Find(user); UserData usuario = new UserData() { US_Email = ud.US_Email }; //Remove items from shopping cart and add to User purchases foreach(var c in cart){ var photoUs = db.Photo.Find(c.C_PH_Id); usuario.Photo.Add(photoUs); Purchases pur = new Purchases(); try { pur.PUR_PH_Id = c.C_PH_Id; pur.PUR_US_Id = c.C_US_Id; pur.PUR_DatePurchase = DateTime.Now; pur.Photo = c.Photo; db.Purchases.Add(pur); } catch (Exception e) { Console.WriteLine(e); RedirectToAction("ErrorPage", "Error"); } DeleteItem(c.C_Id); addToNotifications(c.C_PH_Id, 2); } db.SaveChanges(); ActionResult x = await SendPhoto(usuario); return View(); }
private void ByDateFilter( Purchases.Criteria criteria ) { this.LoadReceipts(criteria); }
/// <summary> /// This method returns SqlCommand object for receipts list /// </summary> /// <param name="criteria">Options for receipts to select</param> /// <returns></returns> public static System.Data.SqlClient.SqlCommand Receipts(Purchases.Criteria criteria ) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); string joins = "", conditions = "", orders = "", tp = ""; orders = "ORDER BY r.Paid, r.ReceiptID"; if (criteria != null){ if (criteria.Top > 0){ tp = "TOP " + criteria.Top.ToString(); orders = "ORDER BY r.Price DESC"; } if ((criteria.Categories != null) && (criteria.Categories.Count > 0)){ joins += "LEFT JOIN (SELECT DISTINCT rc.ReceiptID, p.Category\n" + " FROM Purchases.ReceiptContents AS rc\n" + " JOIN Producer.Products AS p\n" + " ON p.ProductID = rc.ProductID) AS rcc\n" + " ON rcc.ReceiptID = r.ReceiptID\n"; conditions += (conditions.Length == 0 ? "WHERE " : "\nAND "); string[] parameters = new string[criteria.Categories.Count]; for (int i = 0; i < criteria.Categories.Count; i++){ parameters[i] = string.Format("@Category{0}", i); cmd.Parameters.AddWithValue(parameters[i], criteria.Categories[i]); } conditions += string.Format("rcc.Category IN( {0} )", string.Join(", ", parameters)); } if ((criteria.Vendors != null) && (criteria.Vendors.Count > 0)) { conditions += (conditions.Length == 0 ? "WHERE " : "\nAND "); string[] parameters = new string[criteria.Vendors.Count]; for (int i = 0; i < criteria.Vendors.Count; i++) { parameters[i] = string.Format("@Vendor{0}", i); cmd.Parameters.AddWithValue(parameters[i], criteria.Vendors[i]); } conditions += string.Format("r.Vendor IN( {0} )", string.Join(", ", parameters)); } if ((criteria.Dates != null) && (criteria.Dates.Length > 0)){ string sign = ""; if (DateFilterType.More == criteria.DateFilter) sign = ">"; else if (DateFilterType.MoreOrEqual == criteria.DateFilter) sign = ">="; else if (DateFilterType.Less == criteria.DateFilter) sign = "<"; else if (DateFilterType.LessOrEqual == criteria.DateFilter) sign = "<="; else if (DateFilterType.Equal == criteria.DateFilter) sign = "="; conditions += (conditions.Length == 0 ? "WHERE " : "\nAND "); switch( criteria.DateFilter ){ case DateFilterType.Between: conditions += "r.Paid BETWEEN @StartDate AND @EndDate"; cmd.Parameters.AddWithValue("@StartDate", criteria.Dates[0]); cmd.Parameters.AddWithValue("@EndDate", criteria.Dates[1]); break; case DateFilterType.More: case DateFilterType.MoreOrEqual: case DateFilterType.Less: case DateFilterType.LessOrEqual: case DateFilterType.Equal: conditions += "r.Paid " + sign + " @TargetDate"; cmd.Parameters.AddWithValue("@TargetDate", criteria.Dates[0]); break; case DateFilterType.Exact: default: string[] parameters = new string[criteria.Dates.Length]; for (int i = 0; i < criteria.Dates.Length; i++){ parameters[i] = string.Format("@Paid{0}", criteria.Dates[i].ToShortDateString() ); cmd.Parameters.AddWithValue(parameters[i], criteria.Dates[i].ToShortDateString()); } conditions += string.Format("r.Paid IN( {0} )", string.Join(", ", parameters)); break; } } } string sQuery = "SELECT " + tp + " r.ReceiptID, r.Paid, r.Price, r.Discount, r.DiscountCard,\n" + " r.Comment, r.Vendor, r.Deleted, r.Number,\n" + " r.Created, r.Updated,\n" + " v.VendorName, v.VendorType\n" + "FROM Purchases.Receipts AS r\n" + "LEFT JOIN Purchases.Vendors AS v\n" + " ON v.VendorID = r.Vendor\n" + joins + conditions + "\n" + orders; cmd.CommandTimeout = 0; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = sQuery; return cmd; }