/// <summary> /// 新建淘汰信息 /// </summary> /// <param name="newInfo"></param> /// <returns></returns> public bool CreateEliminateInfo(EliminateInfo newInfo) { var salesService = new SaleService(); var taskStatusTypeService = new TaskStatusTypeService(); var taskService = new TaskService(); var pigService = new PigService(); var pigInfo = new PigInfo(); var newSale = new sale { TaskId = long.Parse(newInfo.TaskNumber), EmployeeId = long.Parse(newInfo.EmployeeName), SaleType = "淘汰", Memo = newInfo.Meno }; foreach (Detail salesPigInfo in newInfo.EliminateInfoPigDetail) { newSale.sale_pig.Add(new sale_pig { Time = salesPigInfo.DetailTime, PigId = long.Parse(salesPigInfo.Pig) }); pigInfo.SetState(long.Parse(salesPigInfo.Pig), true); } salesService.Insert(newSale); task_status_type taskStatusType = taskStatusTypeService.FindByName("已完成"); task task = taskService.Find(long.Parse(newInfo.TaskNumber)); if (taskStatusType != null && task != null) { task.TaskStatusId = taskStatusType.Id; taskService.Update(task); } return true; }
public BO(IDAO dao) { if (dao == null) throw new ArgumentNullException(nameof(dao)); DAO = dao; ClientService = new ClientService(dao.ClientRepository); GoodsService = new GoodsService(dao.GoodsRepository); ManagerService = new ManagerService(dao.ManagerRepository); SaleService = new SaleService(dao.SaleRepository); Log.Trace("BO created."); }
/// <summary> /// 查看销售信息 /// </summary> /// <param name="taskNumber">任务编号</param> /// <returns></returns> public SalesInfo CheckSalesInfo(string taskNumber) { var checkSalesInfo = new SalesInfo(); var salesService = new SaleService(); checkSalesInfo.SalesInfoPigDetail = new List<Detail>(); checkSalesInfo.SalesInfoDetail = new List<SalesInfoDetail>(); var saleTaskQualityService = new SaleTaskQualityService(); var transferService = new TransferService(); task task = new TaskService().FindByTaskNumber(taskNumber); if (task == null) return null; sale sale = salesService.FindByTaskId(task.Id).FirstOrDefault(); if (sale == null) return null; checkSalesInfo.TaskNumber = taskNumber; checkSalesInfo.EmployeeName = sale.employee.Name; checkSalesInfo.Meno = sale.Memo; checkSalesInfo.Customer = task.customer.Name; foreach (sale_task_quality saleTaskItem in saleTaskQualityService.FindByTaskId(task.Id)) { checkSalesInfo.SalesInfoDetail.Add(new SalesInfoDetail { PigType = saleTaskItem.pig_type.Name, Price = saleTaskItem.Price, Quantity = saleTaskItem.Quality }); } foreach (sale_pig salePigItem in sale.sale_pig) { transfer firstOrDefault = transferService.FindByPigId(salePigItem.PigId).OrderByDescending(m => m.Time).FirstOrDefault(); if (firstOrDefault != null) if (salePigItem.Time != null) checkSalesInfo.SalesInfoPigDetail.Add(new Detail { PigHouse = firstOrDefault.pigsty.pig_house.pig_house_type . Name + firstOrDefault.pigsty.pig_house.Number, Pigsty = firstOrDefault.pigsty.Number + "", Pig = salePigItem.pig.Number, DetailTime = (DateTime) salePigItem.Time }); } return checkSalesInfo; }
private void checkout_bt_Click(object sender, EventArgs e) { try { if (cust_contact_tb.Text == "" || cashPaid_tb.Text == "" || total_tb.Text == "" || change_tb.Text == "") { MessageBox.Show("Textbox Empty!"); } else {//////////pdf Document doc = new Document(iTextSharp.text.PageSize.A4); string fileName = "D:\\Dropbox\\Project\\Project 5.1\\Medical Store\\receipts\\" + saleId_tb.Text + ".pdf"; PdfWriter pd = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create)); doc.Open(); Paragraph para; para = new Paragraph("****Medical Store****"); para.Alignment = 1; doc.Add(para); para = new Paragraph("Date: " + date.Text); para.Alignment = 0; doc.Add(para); para = new Paragraph("Time: " + DateTime.Now.TimeOfDay); para.Alignment = 2; doc.Add(para); para = new Paragraph("SaleId: " + saleId_tb.Text); para.Alignment = 2; doc.Add(para); para = new Paragraph("Customer Contact: " + cust_contact_tb.Text); para.Alignment = 2; doc.Add(para); para = new Paragraph("Salesman: " + user.UserId + "\n\n"); para.Alignment = 2; doc.Add(para); PdfPTable table = new PdfPTable(4); PdfPCell cell = new PdfPCell(new Phrase("Medicine Name")); cell.HorizontalAlignment = 1; table.AddCell(cell); cell = new PdfPCell(new Phrase("Quantity")); cell.HorizontalAlignment = 1; table.AddCell(cell); cell = new PdfPCell(new Phrase("Unit Price")); cell.HorizontalAlignment = 1; table.AddCell(cell); cell = new PdfPCell(new Phrase("Amount")); cell.HorizontalAlignment = 1; table.AddCell(cell); pursServ = new PurchaseService(); List <Purchase> purc = pursServ.GetAll(pur.SaleId); foreach (var item in purc) { table.AddCell(item.MedName); table.AddCell(item.Quantity.ToString()); table.AddCell(item.UnitPrice.ToString()); table.AddCell(item.Amount.ToString()); } doc.Add(table); para = new Paragraph("Total: " + total_tb.Text + "\nCash Paid: " + cashPaid_tb.Text + "\nChange: " + change_tb.Text + "\n"); para.Alignment = 2; doc.Add(para); doc.Close(); ///// Profit pursServ = new PurchaseService(); List <Purchase> purs2 = pursServ.GetAll(pur.SaleId); foreach (var item in purs2) { Medicine med = new Medicine(); medServ = new MedicineService(); med = medServ.GetMed(item.MedId); med.Quantity = med.Quantity - item.Quantity; medServ = new MedicineService(); int res = medServ.UpdateMed(med); prof = new Profit(); prof.SaleId = item.SaleId; prof.MedId = item.MedId; prof.Date = Convert.ToDateTime(date.Text); prof.Income = item.Amount - (med.BuyingPrice * item.Quantity); profServ = new ProfitService(); int rsl = profServ.Insert(prof); } //// History HistoryService hisServ; CustHistory custHis; pursServ = new PurchaseService(); List <Purchase> purs = pursServ.GetAll(pur.SaleId); List <CustHistory> histories = new List <CustHistory>(); foreach (var item in purs) { custHis = new CustHistory(); custHis.Date = Convert.ToDateTime(date.Text); custHis.Contact = Convert.ToInt32(cust_contact_tb.Text); custHis.SaleId = Convert.ToInt32(item.SaleId); custHis.MedName = item.MedName; custHis.Quantity = item.Quantity; hisServ = new HistoryService(); int rst = hisServ.Insert(custHis); } //////Sale pursServ = new PurchaseService(); List <Purchase> purs1 = pursServ.GetAll(pur.SaleId); List <Sale> sales = new List <Sale>(); foreach (var item in purs1) { sal = new Sale(); sal.Date = Convert.ToDateTime(date.Text); sal.SaleId = item.SaleId; sal.MedName = item.MedName; sal.Quantity = item.Quantity; salServ = new SaleService(); int rlt = salServ.Insert(sal); } new Home(user).Show(); this.Hide(); } } catch (Exception ex) { MessageBox.Show(ex.StackTrace); } }
protected void SetUp() { Service = new SaleService(); }
public SaleController() : base(new SaleService(new BaseRepository <Sale>(BusinessDbContext.Create()))) { this.saleService = this.Service as SaleService; }
/// <summary> /// 删除淘汰的相关信息 /// </summary> /// <param name="taskNumber">任务编号</param> /// <returns></returns> public bool DelEliminateInfo(string taskNumber) { var salesService = new SaleService(); var salePigService = new SalePigService(); var taskStatusTypeService = new TaskStatusTypeService(); var pigInfo = new PigInfo(); task task = new TaskService().FindByTaskNumber(taskNumber); if (task == null) return false; foreach (sale sale in salesService.FindByTaskId(task.Id)) { foreach (sale_pig EliminatePig in salePigService.FindBySaleId(sale.Id)) { salePigService = new SalePigService(); salePigService.Delete(salePigService.Find(EliminatePig.Id)); pigInfo.SetState(EliminatePig.Id, false); } salesService = new SaleService(); salesService.Delete(salesService.Find(sale.Id)); } task_status_type taskStatusType = taskStatusTypeService.FindByName("已完成"); task.TaskStatusId = taskStatusType.Id; return true; }
/// <summary> /// 更新修改淘汰信息 /// </summary> /// <param name="updateInfo">淘汰信息页面类</param> /// <returns></returns> public bool UpdateEliminateInfo(EliminateInfo updateInfo) { var salesService = new SaleService(); var salePigService = new SalePigService(); task task = new TaskService().FindByTaskNumber(updateInfo.TaskNumber); var pigInfo = new PigInfo(); int count = 0; if (task == null) return false; foreach (sale sale in salesService.FindByTaskId(task.Id)) { sale.EmployeeId = long.Parse(updateInfo.EmployeeName); sale.Memo = updateInfo.Meno; salesService.Update(sale); List<sale_pig> saleList = salePigService.FindBySaleId(sale.Id); foreach (sale_pig salePig in saleList) { pigInfo.SetState(salePig.PigId, false); if (count < updateInfo.EliminateInfoPigDetail.Count) { salePig.PigId = long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig); salePig.Time = updateInfo.EliminateInfoPigDetail[count].DetailTime; salePigService.Update(salePig); pigInfo.SetState(long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig), true); } else { salePigService = new SalePigService(); salePigService.Delete(salePigService.Find(salePig.Id)); } count++; } for (; count < updateInfo.EliminateInfoPigDetail.Count; count++) { salePigService.Insert(new sale_pig { SaleId = sale.Id, PigId = long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig), Time = updateInfo.EliminateInfoPigDetail[count].DetailTime }); pigInfo.SetState(long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig), true); } } return true; }
public CreateSale(EmployeeService employeeService, SaleService saleService) { EmployeeService = employeeService; SaleService = saleService; }
public void TearDown() { _repository = null; _service = null; }
public void Setup() { SaleService = new SaleService(SaleRepositoryMock.Object, new SaleValidator()); }
static void Main(string[] args) { var context = new StoreSystemDbContext(); var dateNow = new DateTimeNowProvider(); var addressService = new AddressService(context); var cityService = new CityService(context); var countryService = new CountryService(context); var saleService = new SaleService(context, new DateTimeNowProvider()); var clientService = new ClientService(context); var productService = new ProductService(context); var offerService = new OfferService(context, dateNow); var supplierService = new SupplierService(context); var purchaseService = new PurchaseService(context, new DateTimeNowProvider()); var warehouseService = new WarehouseService(context); addressService.GetListOfAllClientsbyID(1); cityService.GetListOfAllClientsbyName("Sofia"); countryService.GetListOfAllClientsbyName("Bulgaria"); clientService.FindClientWithAddress(1); clientService.GetAllClients(0, 100, "tash"); clientService.UpdateClient(1, null, "321654987", null, null, null, null, null); clientService.GetClientSales(4); try { //var a = clientService.CreateClient("Pesho", "123456789", "*****@*****.**", "0888500050", // new Address() { Name = "Nova Strasse" }, new City() { Name = "Berlin" }, new Country() { Name = "Germany" }); //Console.WriteLine(a?.ClientID + " " +a?.Name); //addressService.CreateAddress("Malinova dolina 2"); //addressService.CreateAddress("Ovcha kupel otzad"); //addressService.CreateAddress("Krasna polqna bai cig"); //addressService.CreateAddress("ul. Krasnorech"); //addressService.CreateAddress("jk. Liulin 11"); //addressService.CreateAddress("Cheroshova gradina 5"); //cityService.CreateCity("Sofia"); //cityService.CreateCity("Dolno Uino"); //cityService.CreateCity("Pelnik"); //productService.CreateProduct("Piron 1.2", "pcs", 100, 1.50m, 1.80m); //productService.CreateProduct("Nailon 2mk", "pcs", 1200, 2.60m, 3.80m); //productService.CreateProduct("Konop", "pcs", 45, 3.50m, 5.80m); //productService.CreateProduct("Lager 6.19", "pcs", 55, 8.20m, 10.70m); //productService.CreateProduct("Bager JCB", "pcs", 5, 50000.00m, 60000.00m); //productService.CreateProduct("Fadroma Liebherr", "pcs", 2, 61000.00m, 66000.00m); //productService.CreateProduct("Lopata prava", "pcs", 35, 10.30m, 13.80m); //productService.CreateProduct("Chuk kofrajen", "pcs", 190, 18.90m, 22.80m); //saleService.CreateSale( // clientService.FindClientByName("Pesho"), // 7, // addressService.FindAddressByName("Nova Strasse"), // cityService.FindCityByName("Berlin"), // countryService.FindCountryByName("Germany") // ); //saleService.AddProductsToSale(1, new KeyValuePair<string, decimal>("Konop", 10), // new KeyValuePair<string, decimal>("Lager 6.19", 20), // new KeyValuePair<string, decimal>("Lopata prava", 8)); //var a =saleService.GetSaleQuantityByDate(new DateTime(2018, 1, 1), new DateTime(2019, 12, 1)); //Console.WriteLine(a.ToString("f2")); //var (a, b) = Spliter(Console.ReadLine()); //Console.WriteLine(a); //Console.WriteLine(String.Join(", ",b)); saleService.AddProductsToSale(4, new ProductQuantityDto("pironche", 1), new ProductQuantityDto("lopata prava", 1)); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public ActionResult Test(Pay pay) { if (false == ModelState.IsValid) { return(View()); } long token = 0; short paymentStatus = short.MinValue; ClientSaleResponseData responseData = null; using (var service = new SaleService()) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((o, xc, xch, sslP) => true); service.Url = ConfigHelper.ParsianPGWSaleServiceUrl; var saleRequest = new ClientSaleRequestData(); saleRequest.LoginAccount = ConfigHelper.LoginAccount; //make sure you set the CallBackUrl property. because after user has completed Payment on IPG page, it will be redirected to the callback url you provided //to get you back result of the user Payment on IPG. saleRequest.CallBackUrl = ConfigHelper.SalePaymentCallback; //Amount is not used. you should not assign a value to this property. saleRequest.Amount = pay.Amount; //saleRequest.AdditionalData = model.AdditionalData; //Order Id MUST be UNIQUE at all times. if a duplicated Order Id is received from your request, you will get Status=-112 var a = new Random(DateTime.Now.Ticks.GetHashCode()); saleRequest.OrderId = a.Next(1000000, 999999999); saleRequest.AdditionalData = "111101789012345678901"; responseData = service.SalePaymentRequest(saleRequest); paymentStatus = responseData.Status; //check Status property of the response object to see if the operation was successful. if (responseData.Status == Constants.ParsianPaymentGateway.Successful) { //if everything is OK (LoginAccount and your IP address is valid in the Parsian PGW), save the token in a data store // to use it for redirectgion of your web site's user to the Parsian IPG (Internet Payment Gateway) page to complete payment. token = responseData.Token; //you must save the token in a data store for further support and resolving Session["Token"] = token; } else { //logger.Error($"Parsian PGW service call status code : {responseData.Status}"); } } if (paymentStatus == Constants.ParsianPaymentGateway.Successful && token > 0L) { //first, save token to your database to be able to track payment process with your business. //after successfully retrieved a token from Parsian PGW, redirect user to Parsian IPG to complete the payment operation. var redirectUrl = string.Format(ConfigHelper.ParsianIPGPageUrl, token); //return Json(new { status = 0, location = redirectUrl }); return(Redirect(redirectUrl)); } else { ViewBag.Error = "Error conecting to pay service"; //var mdl = new PaymentRequestResponseModel() //{ // Message = responseData?.Message, // Status = responseData?.Status, // Token = responseData?.Token //}; return(View()); } }
public async Task <ActionResult> Delete(int id) { await Task.Run(() => SaleService.DeleteSale(id)); return(RedirectToAction("Index")); }
public MenuController(MenuService menuService, IUtil util, OrderService orderService, SaleService saleService) { _menuService = menuService; _util = util; _orderService = orderService; _saleService = saleService; }
public PaymentController(KassaPaymentService kassaPaymentService, SaleService saleService) { _kassaPaymentService = kassaPaymentService; _saleService = saleService; }
public PresenterAddSale(ISaleRepository IsaleR, IAddSaleView view) { saleService = new SaleService(IsaleR); _view = view; }
public void Setup() { BaseSqlTest.SeedDatabase(); _repository = new SaleSqlRepository(); _service = new SaleService(_repository); }
public void CreateSaleService_WithUow_ShouldPerform() { var saleService = new SaleService(GetValidUowStubBase().Object); Assert.IsNotNull(saleService); }
public SalesController() { service = new SaleService(); }
public OrderController(OrderService orderService, IUtil util, MenuService menuService, SaleService saleService) { _orderService = orderService; _util = util; _menuService = menuService; _saleService = saleService; }
/// <summary> /// 淘汰信息列表 /// </summary> /// <returns></returns> public IEnumerable<Info> GetEliminateInfoList() { var salesService = new SaleService(); var salePigService = new SalePigService(); return (from saleItem in salesService.FindAll() let salePigItem = salePigService.FindBySaleId(saleItem.Id).OrderByDescending(m => m.Time).FirstOrDefault() let dateTime = salePigItem.Time where dateTime != null && saleItem.SaleType=="淘汰" select new Info { TaskNumber = saleItem.task.TaskNumber, EmployeeName = saleItem.employee.Name, Time = (DateTime)dateTime, Meno = saleItem.Memo }).ToList(); }
public void Initialize() { historyTableRepository = Substitute.For <IHistoryTableRepository>(); traderStockTableRepository = Substitute.For <ITraderStockTableRepository>(); traderTableRepository = Substitute.For <ITraderTableRepository>(); traderTableRepository.GetById(5).Returns(new TraderEntityDB() { Id = 5, Name = "Muhamed", Surname = "Ali", Balance = 123123.0M }); traderTableRepository.GetById(40).Returns(new TraderEntityDB() { Id = 40, Name = "Brad", Surname = "Pitt", Balance = 1243123.0M }); stockTableRepository = Substitute.For <IStockTableRepository>(); stockTableRepository.GetById(7).Returns(new StockEntityDB() { Id = 7, Name = "Pepsi", PricePerItem = 123.0M }); stockTableRepository.GetById(20).Returns(new StockEntityDB() { Id = 20, Name = "Shmepsi", PricePerItem = 33.0M }); this.traderStocksTable = new List <StockToTraderEntityDB>() { new StockToTraderEntityDB() { Id = 1, TraderId = 5, StockId = 7, StockCount = 4, PricePerItem = 123.0M }, new StockToTraderEntityDB() { Id = 2, TraderId = 5, StockId = 20, StockCount = 2, PricePerItem = 33.0M }, new StockToTraderEntityDB() { Id = 3, TraderId = 40, StockId = 7, StockCount = 2, PricePerItem = 33.0M } }; traderStockTableRepository.GetStocksFromSeller(Arg.Any <BuyArguments>()) .Returns((callInfo) => { var buyArguments = callInfo.Arg <BuyArguments>(); var retVal = this.traderStocksTable.First(w => w.TraderId == buyArguments.SellerID && w.StockId == buyArguments.StockID); return(retVal); }); traderStockTableRepository.ContainsSeller(Arg.Any <BuyArguments>()) .Returns((callInfo) => { var buyArguments = callInfo.Arg <BuyArguments>(); try { var retVal = this.traderStocksTable.First(w => w.TraderId == buyArguments.SellerID && w.StockId == buyArguments.StockID); } catch (Exception) { return(false); } return(true); }); traderStockTableRepository.ContainsCustomer(Arg.Any <BuyArguments>()) .Returns((callInfo) => { var buyArguments = callInfo.Arg <BuyArguments>(); try { var retVal = this.traderStocksTable.First(w => w.TraderId == buyArguments.CustomerID && w.StockId == buyArguments.StockID); } catch (Exception) { return(false); } return(true); }); traderStockTableRepository.Contains(Arg.Any <StockToTraderEntityDB>()) .Returns((callInfo) => { var stockToTrader = callInfo.Arg <StockToTraderEntityDB>(); try { var retVal = this.traderStocksTable.First(w => w.TraderId == stockToTrader.TraderId && w.StockId == stockToTrader.StockId); } catch (Exception) { return(false); } return(true); }); traderTableRepository.ContainsById(5).Returns(true); traderTableRepository.ContainsById(40).Returns(true); saleHandler = new SaleService(this.traderStockTableRepository, this.traderTableRepository, this.historyTableRepository); }
public PaymentParsianService(SaleService saleService, ClientSaleRequestData request) { _saleService = saleService; _request = request; }
/// <summary> /// 删除销售的相关信息 /// </summary> /// <param name="taskNumber">任务编号</param> /// <returns></returns> public bool DelsalesInfo(string taskNumber) { var salesService = new SaleService(); var salePigService = new SalePigService(); var pigInfo = new PigInfo(); task task = new TaskService().FindByTaskNumber(taskNumber); if (task == null) return false; foreach (sale sale in salesService.FindByTaskId(task.Id)) { foreach (sale_pig salePig in salePigService.FindBySaleId(sale.Id)) { salePigService = new SalePigService(); salePigService.Delete(salePigService.Find(salePig.Id)); pigInfo.SetState(salePig.Id, false); } salesService = new SaleService(); salesService.Delete(salesService.Find(sale.Id)); } return true; }
public SaleController() { _context = new OrderDbContext(); _saleApplicationService = new SaleService(_context); }
public TradeSimulation(TradersService traders, TraderStocksService traderStocks, SaleService saleService, ILogger logger) { this.traders = traders; this.traderStocks = traderStocks; this.saleService = saleService; this.logger = logger; logger.InitLogger(); }
protected void Page_Load(object sender, EventArgs e) { SS = new SaleService(); string s = Request["value"].ToString(); p_id.Text = s; year = DateTime.Now.Year.ToString();; month = DateTime.Now.Month.ToString(); day = DateTime.Now.Day.ToString(); hour = DateTime.Now.Hour.ToString(); minute = DateTime.Now.Minute.ToString(); s_date.Text = year + "-" + month + "-" + day; s_id.Text = year + month + day + hour + minute; // s_summary.Text = amo * num; //创建数据库链接 MDB = new MyDatabase(); constr = MDB.getConnection(); MySqlConnection mycon = new MySqlConnection(constr); mycon.Open(); sql = string.Format("select p_brand,p_model,p_color,price_sale from phone_table where p_id ={0}", Convert.ToInt32(s)); //查询 显示结果 MySqlCommand mycmd = new MySqlCommand(sql, mycon); MySqlDataReader reader = null; reader = mycmd.ExecuteReader(); while (reader.Read()) { brand.Text = reader[0].ToString(); model.Text = reader[1].ToString(); color.Text = reader[2].ToString(); s_price.Text = reader[3].ToString(); /* s_date.Text = reader[1].ToString(); * s_e_id.Text = reader[3].ToString(); * s_amount.Text = reader[4].ToString(); * s_summary.Text = reader[5].ToString(); * * s_get.Text = reader[7].ToString(); * s_return.Text = reader[8].ToString(); * s_way.Text = reader[9].ToString(); * pr_number.Text = reader[10].ToString(); */ } reader.Close(); mycon.Close(); // 默认输入 double price = double.Parse(s_price.Text.ToString()); double m = double.Parse(amount.Text.ToString()); double sum = price * m; s_summary.Text = "" + sum; s_get.Text = s_summary.Text; s_return.Text = "0"; s_e_id.Text = "34601"; s_way.Text = "零售"; pr_number.Text = "4001"; }
public AdminController() { _db = new SkladContext(); _statisticService = new StatisticService(_db); _saleService = new SaleService(_db); }