private void SilButtonClicked(object sender, RoutedEventArgs e) { var context = new MarketDBContext(); var selectedItems = SupplierList.SelectedItems; if (selectedItems.Count > 0) { string message = $"Seçilen {selectedItems.Count} tedarikçiyi silmek istiyor musunuz?"; string caption = "Onay"; MessageBoxButton buttons = MessageBoxButton.YesNo; MessageBoxImage icon = MessageBoxImage.Question; if (MessageBox.Show(message, caption, buttons, icon) == MessageBoxResult.Yes) { foreach (Supplier supplier in selectedItems) { Supplier sup = context.Suppliers.Find(supplier.ID); context.Suppliers.Remove(sup); } context.SaveChanges(); RefreshList(SupplierList); } else { return; } } }
private void OdeButtonClicked(object sender, EventArgs e) { var context = new MarketDBContext(); if (PaymentAmountText.Text != "") { CustomerDebt cd = context.CustomerDebts.Find(this.SelectedCustomerIDNumber); if (double.Parse(PaymentAmountText.Text) <= cd.DebtAmount) { double InputPaymentAmount = double.Parse(PaymentAmountText.Text); Payment cp = new Payment(this.SelectedCustomerIDNumber, 0, InputPaymentAmount, DateTime.Now); context.Payments.Add(cp); CustomerDebt tcd = context.CustomerDebts.Find(this.SelectedCustomerIDNumber); tcd.DebtAmount -= InputPaymentAmount; context.SaveChanges(); RefreshList(PaymentList); RefreshSum(SumLabel); PaymentAmountText.Text = String.Empty; } else { MessageBox.Show("Mevcut borçtan fazla girdiniz!"); } } }
public TrendChartPage() { var context = new MarketDBContext(); InitializeComponent(); ProductList.ItemsSource = context.Products.ToList(); }
private void OdeButtonClicked(object sender, EventArgs e) { if (PaymentAmountText.Text != "") { var context = new MarketDBContext(); // This operation removes the currency part of the string if (double.Parse(PaymentAmountText.Text) <= double.Parse(SumLabel.Content.ToString().Remove(SumLabel.Content.ToString().Length - 1, 1))) { double InputPaymentAmount = double.Parse(PaymentAmountText.Text); Payment p = new Payment(0, SelectedSupplierID, InputPaymentAmount, DateTime.Now); context.Payments.Add(p); context.SaveChanges(); RefreshList(PaymentList); RefreshSum(SumLabel); PaymentAmountText.Text = ""; } else { MessageBox.Show("Wrong amount!"); } } }
private void EkleButtonClicked(object sender, RoutedEventArgs e) { var context = new MarketDBContext(); if (NameText.Text != "" && LastNameText.Text != "" && IDNumberText.Text != "") { string InputName = NameText.Text; string InputLastName = LastNameText.Text; long InputIDNumber = long.Parse(IDNumberText.Text); var query = context.Customers.Where(s => s.IDNumber == InputIDNumber); if (query.Count() == 0) { //if customer was not registered. Customer cst = new Customer(InputIDNumber, InputName, InputLastName); context.Customers.Add(cst); context.SaveChanges(); RefreshList(CustomerList); NameText.Text = String.Empty; LastNameText.Text = String.Empty; IDNumberText.Text = String.Empty; } else { MessageBox.Show("Girilen kimlik numarasına sahip kayıtlı müşteri var!"); } } else { MessageBox.Show("Lütfen isim, soyisim ve kimlik numarası giriniz!"); } }
private void RefreshList(string input) { var context = new MarketDBContext(); var querySale = context.Sales; var queryCstmr = context.Customers; List <SaleItem> si = new List <SaleItem>(); if (querySale.Any()) { foreach (Sale sale in querySale.Where(c => c.ID.ToString().Contains(input)).ToList()) { var cstmr = queryCstmr.Find(sale.CustomerIDNumber); string cFullName = cstmr == null ? "Peşin satış" : cstmr.Name + " " + cstmr.LastName; si.Add(new SaleItem() { FullName = cFullName, ID = sale.ID, Date = sale.Date }); } SaleRecordList.ItemsSource = si.OrderBy(i => i.Date); } else { SaleRecordList.ItemsSource = si; } }
private void LoginButtonClicked(object sender, RoutedEventArgs e) { var context = new MarketDBContext(); // Get inputs from UsernameText PasswordText text boxes string InputUsername = UsernameText.Text; string InputPassword = PasswordText.Password; // Check if credientials are correct // hash input password here var query = context.Users.Where(s => s.Username == InputUsername && s.PasswordHash == InputPassword); if (query.Count() != 0) { this.DialogResult = true; } else { MessageBox.Show("Kullanıcı adı veya parola hatalı!"); this.DialogResult = false; } }
private void EkleButtonClicked(object sender, RoutedEventArgs e) { var context = new MarketDBContext(); if (NameText.Text != "" && PhoneNumberText.Text != "") { string InputName = NameText.Text; string InputPhoneNumber = PhoneNumberText.Text; var query = context.Suppliers.Where(s => s.Name == InputName); if (query.Count() == 0) { //if customer was not registered. Supplier sup = new Supplier(InputName, InputPhoneNumber); context.Suppliers.Add(sup); context.SaveChanges(); RefreshList(SupplierList); NameText.Text = String.Empty; PhoneNumberText.Text = String.Empty; } else { MessageBox.Show("Girilen isimde tedarikçi bulunmakta."); } } else { MessageBox.Show("Lütfen isim ve telefon numarası giriniz."); } }
public ProductController(MarketDBContext context, IMapper mapper, UserManager <AspNetUsers> userManager, IProductService productService) { _context = context; _mapper = mapper; _userManager = userManager; _productService = productService; }
private void RefreshList(string input) { // Refresh the list with customers with the given input text var context = new MarketDBContext(); List <Customer> ls = context.Customers.Where(c => c.IDNumber.ToString().Contains(input)).ToList(); CustomerList.ItemsSource = ls; }
private void RefreshList(string input) { // Refresh the list with customers with the given input text var context = new MarketDBContext(); List <Supplier> ls = context.Suppliers.Where(s => s.Name.Contains(input)).ToList(); SupplierList.ItemsSource = ls; }
public void RefreshSum(Label label) { var context = new MarketDBContext(); CustomerDebt da = context.CustomerDebts.Find(this.SelectedCustomerIDNumber); double sum = da.DebtAmount; // Set content of the label to sum SumLabel.Content = sum.ToString(); }
public void AllCustomerReport(int choice) { var context = new MarketDBContext(); var resultCustomer = context.Database.SqlQuery<Customer>($@"select IDNumber, Name, Lastname from Customers"); List<Customer> cList = resultCustomer.ToList(); //Check if there is any customer if (cList.Count() == 0) { Console.WriteLine("Veri tabanında kayıtlı müşteri yok"); return; } if (choice == 1) { AllPdf(cList); } else { AllExcel(cList); } }
public void SingleCustomerReport(long CustomerID, int choice) { var context = new MarketDBContext(); Customer customer = context.Customers.Find(CustomerID); var result = context.Database.SqlQuery<ReportItem>($@"EXEC CustomerSales @InputID = {CustomerID};"); List<ReportItem> riList = result.ToList(); if (riList.Count == 0) { Console.WriteLine("Seçilen müşteri satın alım yapmamış"); return; } if (choice == 1) { SinglePdf(customer, riList); } else { SingleExcel(customer, riList); } }
public SalePage() { InitializeComponent(); var context = new MarketDBContext(); var queryPrd = context.Products; var queryStock = context.Stocks; if (queryStock.Any()) { List <StockItem> items = new List <StockItem>(); for (int i = 1; i <= queryStock.Count(); i++) { string color = ""; var product = queryPrd.Find(i); var productStock = queryStock.Find(product.Barcode); int amountPercent; if (product.WarningLimit != 0) { amountPercent = (int)((100 * productStock.Amount) / product.WarningLimit); // We have less products than the warning limit if ((product.WarningLimit / 2) > productStock.Amount) { // Less than %50 of the wanted amount color = "Crimson"; } else if (amountPercent < 80) { // Less than %50 of the wanted amount color = "Yellow"; } else { // Equal or More than the wanted amount color = "Green"; } items.Add(new StockItem() { Title = product.Name, Completion = amountPercent, Color = color }); } } StockList.ItemsSource = items.OrderBy(i => i.Completion); } }
private void OnaylaButtonClicked(object sender, RoutedEventArgs e) { var context = new MarketDBContext(); int DispatchID = int.Parse(DispatchNoLabel.Content.ToString()); string SupplierName = (string)SupplierNameLabel.Content; Supplier supplier = context.Suppliers.Where(s => s.Name == SupplierName).First(); // If there are products on the list and dispatchID is new if (context.Storages.Where(x => x.DispatchNoteID == DispatchID).Any()) { System.Windows.MessageBox.Show("Verilen ID'ye sahip sistemde kayıtlı irsaliye var."); return; } if (ProductList.Items.Count > 0) { for (int i = 0; i < ProductList.Items.Count; i++) { ProductItem item = (ProductItem)ProductList.Items.GetItemAt(i); Storage s = new Storage(DispatchID, supplier.ID, item.Barcode, item.Price, item.Amount, DateTime.Now); context.Storages.Add(s); var query = context.Stocks.Where(t => t.Barcode == item.Barcode); //Product already exists in stock if (query.Count() != 0) { //Add how many came in to stock Stock stck = context.Stocks.Find(item.Barcode); stck.Amount += item.Amount; } //Product doesn't exist in stock else { Stock stck = new Stock(item.Barcode, item.Amount); context.Stocks.Add(stck); } } } else { System.Windows.MessageBox.Show("Dosya seçilmedi"); } ProductList.Items.Clear(); DispatchNoLabel.Content = ""; context.SaveChanges(); }
public SaleCountReportPage() { var context = new MarketDBContext(); var result = context.Database.SqlQuery <ProductItem>(@"select 1 as ID, cast(1 as float) as Price, cast(1 as float) as WarningLimit, Products.Name as ""Name"", Products.Barcode as Barcode, SUM(ProductSales.Amount) as Amount from ProductSales join Products on ProductSales.ProductID = Products.ID group by ""Name"", Barcode order by Amount DESC;"); InitializeComponent(); if (result.ToList().Count > 0) { List.ItemsSource = result.ToList(); } }
private void SilButtonClicked(object sender, RoutedEventArgs e) { var context = new MarketDBContext(); var selection = SaleRecordList.SelectedItem; if (selection == null) { MessageBox.Show("Seçim yapılmadı"); return; } SaleItem saleItem = (SaleItem)selection; string message = $"Seçilen satışı silmek istiyor musunuz?"; string caption = "Onay"; MessageBoxButton buttons = MessageBoxButton.YesNo; MessageBoxImage icon = MessageBoxImage.Question; if (MessageBox.Show(message, caption, buttons, icon) == MessageBoxResult.Yes) { //Ask for login var returnValue = false; LogInWindow Login = new LogInWindow(); returnValue = (bool)Login.ShowDialog(); if (returnValue == false) { return; } Sale sale = context.Sales.Find(saleItem.ID); context.Sales.Remove(sale); context.SaveChanges(); RefreshList(""); SaleIDText.Text = String.Empty; } else { return; } }
private void MultiCustomerReportButtonClicked(object sender, RoutedEventArgs e) { var context = new MarketDBContext(); var query = context.CustomerDebts; if (!query.Any()) { MessageBox.Show("There is no customer debt!"); return; } FileSelectionWindow fsw = new FileSelectionWindow(); fsw.ShowDialog(); if (fsw.selection == 0) { return; } ReportFileGenerator fileGenerator = new ReportFileGenerator(); fileGenerator.AllCustomerReport(fsw.selection); }
public void RefreshSum(Label label) { var context = new MarketDBContext(); Supplier sup = context.Suppliers.Find(SelectedSupplierID); var storages = context.Storages.Where(s => s.SupplierID == SelectedSupplierID).ToList(); var payments = context.Payments.Where(p => p.SupplierID == SelectedSupplierID).ToList(); double sum = 0.0; foreach (Storage storage in storages) { sum += (storage.Amount * storage.PriceForUnit); } foreach (Payment payment in payments) { sum -= payment.PaymentAmount; } // Set content of the label to sum SumLabel.Content = sum.ToString() + " ₺"; SupplierLabel.Content = sup.Name; }
private void CustomerReportButtonClicked(object sender, RoutedEventArgs e) { var context = new MarketDBContext(); // Show customer selection window CustomerSelectionWindow csw = new CustomerSelectionWindow(); csw.ShowDialog(); if (csw.selectedCustomerIDNumber == 0) { return; } FileSelectionWindow fsw = new FileSelectionWindow(); fsw.ShowDialog(); if (fsw.selection == 0) { return; } ReportFileGenerator fileGenerator = new ReportFileGenerator(); fileGenerator.SingleCustomerReport(csw.selectedCustomerIDNumber, fsw.selection); }
public StockPage() { InitializeComponent(); var context = new MarketDBContext(); var queryPrd = context.Products; var queryStock = context.Stocks; if (queryStock.Any()) { List <StockItem> items = new List <StockItem>(); for (int i = 1; i <= queryStock.Count(); i++) { var product = queryPrd.Find(i); var productStock = queryStock.Find(product.Barcode); items.Add(new StockItem() { Barcode = productStock.Barcode, Name = product.Name, Amount = productStock.Amount }); } StockList.ItemsSource = items.OrderBy(i => i.Amount); } }
public void RefreshList(ListView List) { var context = new MarketDBContext(); List.ItemsSource = context.Customers.ToList <Customer>(); }
public void AllPdf(List<Customer> cList) { var context = new MarketDBContext(); // Create a A4 sized document Document document = new Document(PageSize.A4, 30, 30, 30, 30); String date = DateTime.Now.ToString("HHmmss"); // Set file path to desktop and create filename string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string fileName = "/Toplu_musteri_raporu"+ date + ".pdf"; PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(path + fileName, FileMode.Create)); if (document.IsOpen() == false) { document.Open(); //Report title string infoText = $"Toplu musteri raporu\n"; Paragraph paragr = new Paragraph(infoText); paragr.Alignment = Element.ALIGN_CENTER; paragr.Font = FontFactory.GetFont(FontFactory.HELVETICA, 12f, BaseColor.GREEN); paragr.SpacingAfter = 30; document.Add(paragr); // Create a table( 5 columns ) PdfPTable table = new PdfPTable(5); table.DefaultCell.Border = Rectangle.NO_BORDER; List<PdfPCell> cellList = new List<PdfPCell>(); cellList.Add(new PdfPCell(new Phrase("Musteri adi"))); cellList.Add(new PdfPCell(new Phrase("Musteri soyadi"))); cellList.Add(new PdfPCell(new Phrase("Toplam satis"))); cellList.Add(new PdfPCell(new Phrase("Toplam odeme"))); cellList.Add(new PdfPCell(new Phrase("Toplam Kalan"))); // Add all customers to the table and calculate foreach (Customer c in cList) { cellList.Add(new PdfPCell(new Phrase(c.Name))); cellList.Add(new PdfPCell(new Phrase(c.LastName))); Customer cstmr = context.Customers.Find(c.IDNumber); var resultSale = context.Database.SqlQuery<ReportItem>($@"EXEC CustomerSales @InputID = {cstmr.IDNumber};"); List<ReportItem> riList = resultSale.ToList(); if (riList.Count == 0) { cellList.Add(new PdfPCell(new Phrase("No purchase"))); } else { double sumPaid = 0; foreach (ReportItem ri in riList) { sumPaid += (ri.Amount * ri.Price); } cellList.Add(new PdfPCell(new Phrase(sumPaid.ToString()))); } var resultPayment = context.Database.SqlQuery<Payment>($@"select ID, CustomerIDNumber, PaymentAmount, SupplierID, Date from Payments where Payments.CustomerIDNumber = {cstmr.IDNumber}"); List<Payment> cpList = resultPayment.ToList(); if (cpList.Count() == 0) { cellList.Add(new PdfPCell(new Phrase("No payment"))); } else { double sumPayment = 0; foreach (Payment cp in cpList) { sumPayment += cp.PaymentAmount; } cellList.Add(new PdfPCell(new Phrase(sumPayment.ToString()))); } var queryDebt = context.CustomerDebts.Find(cstmr.IDNumber); //Check if there is any debt if (queryDebt != null) { cellList.Add(new PdfPCell(new Phrase(queryDebt.DebtAmount.ToString()))); } else { cellList.Add(new PdfPCell(new Phrase("No Debt"))); } } foreach (PdfPCell cell in cellList) { cell.Border = 0; cell.FixedHeight = 25f; cell.HorizontalAlignment = 1; table.AddCell(cell); } document.Add(table); document.Close(); } }
public void AllExcel(List<Customer> cList) { String date = DateTime.Now.ToString("HHmmss"); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string fileName = "/Toplu_musteri_raporu" + date + ".xls"; ExcelPackage.LicenseContext = LicenseContext.NonCommercial; ExcelPackage excel = new ExcelPackage(new FileInfo(path + fileName)); ExcelWorksheet sheetcreate = excel.Workbook.Worksheets.Add("Rapor"); var context = new MarketDBContext(); var rl = new List<ReportList>(); foreach (Customer c in cList) { Customer cstmr = context.Customers.Find(c.IDNumber); var resultSale = context.Database.SqlQuery<ReportItem>($@"EXEC CustomerSales @InputID = {cstmr.IDNumber};"); List<ReportItem> riList = resultSale.ToList(); double purchase = 0; if (riList.Count > 0) { double sumPaid = 0; foreach (ReportItem ri in riList) { sumPaid += (ri.Amount * ri.Price); } purchase = sumPaid; } var resultPayment = context.Database.SqlQuery<Payment>($@"select ID, CustomerIDNumber, PaymentAmount, SupplierID, Date from Payments where Payments.CustomerIDNumber = {cstmr.IDNumber}"); List<Payment> cpList = resultPayment.ToList(); double payment = 0; if (cpList.Count() > 0) { double sumPayment = 0; foreach (Payment cp in cpList) { sumPayment += cp.PaymentAmount; } payment = sumPayment; } var queryDebt = context.CustomerDebts.Find(cstmr.IDNumber); double debt = 0; //Check if there is any debt if (queryDebt != null) { debt = queryDebt.DebtAmount; } rl.Add(new ReportList { Name = c.Name, LastName = c.LastName, Purchase = purchase, PaymentAmount = payment, Debt = debt }); } sheetcreate.Cells.LoadFromCollection(rl); excel.Save(); }
private void ShowButtonClicked(object sender, RoutedEventArgs e) { // Clear the chart if it has values already if (Chart.Series != null) { Chart.Series.Clear(); } // Exception control // If date fields are empty if (StartDatePicker.SelectedDate == null || EndDatePicker.SelectedDate == null) { MessageBox.Show("Lütfen tarihleri seçiniz"); return; } // If selected dates aren't possible if (StartDatePicker.SelectedDate >= EndDatePicker.SelectedDate) { MessageBox.Show("Başlangıç tarihi bitiş tarihinden önce olmalı"); return; } DateTime Start = (DateTime)StartDatePicker.SelectedDate; DateTime End = (DateTime)EndDatePicker.SelectedDate; string dateFormat; if (End.Year != Start.Year) { dateFormat = "dd/MM/yyyy"; } else { dateFormat = "dd/MM"; } Chart.Series = new SeriesCollection { }; // Calculate total days between selected dates int TotalDays = (int)(End - Start).TotalDays + 1; // Get selected Products var selectedItems = ProductList.SelectedItems; if (selectedItems.Count == 0) { MessageBox.Show("Lütfen ürün seçiniz"); return; } ChartValues <string> DateLabels = new ChartValues <string>(); // Loop through selected items and draw a line for every item foreach (Product product in selectedItems) { // Create arrays for x and y values of the graph DateTime[] dates = new DateTime[TotalDays]; ChartValues <double> AmountOfProductsSold = new ChartValues <double>(); var context = new MarketDBContext(); // Loop for total days for (int i = 0; i < TotalDays; i++) { DateTime indexDate = Start.AddDays(i); DateTime queryEndDate = indexDate.AddDays(1); dates[i] = indexDate; // List of sales that are between start and end date List <Sale> saleList = context.Sales.Where(s => s.Date >= indexDate && s.Date < queryEndDate).ToList(); if (saleList.Count() > 0) { double amountSum = 0; // Loop through each sale we found foreach (Sale saleItem in saleList) { // Get each product that is related to the sale we are currently looping // Then check if we have the selected product in those related products List <ProductSale> psList = context.ProductSales.Where(s => s.SaleID == saleItem.ID) .Where(ps => ps.ProductID == product.ID).ToList(); if (psList.Count > 0) { amountSum += psList.First().Amount; } } // Insert the sum to the corresponding chartValue AmountOfProductsSold.Insert(i, amountSum); } else { AmountOfProductsSold.Insert(i, 0); } } foreach (DateTime date in dates) { DateLabels.Add(date.ToString(dateFormat)); } // Input data to the chart Chart.Series.Add(new LineSeries { LineSmoothness = 0, Title = product.Name, Values = AmountOfProductsSold }); } // Set date strings to labels on the X axis Chart.AxisX.First().Labels = DateLabels; }
public UMRepository(UserManager <AppUser> userManager, ApplicationSettings appSettings, MarketDBContext context) { _userManager = userManager; _appSettings = appSettings; _context = context; }
public AccountController(MarketDBContext context) { db = context; }
public GenericRepository(MarketDBContext dbContext) { _dbContext = dbContext; }
public OrderRepository(MarketDBContext context, UserManager <AppUser> userManager) { _context = context; _userManager = userManager; }