public JsonResult GetSalesHistoryDetails(string serialNo) { string userName = null; SalesHistory salesHistory = new SalesHistory(); List <SalesHistory> salesInfoList = new List <SalesHistory>(); try { userName = User.Identity.Name.ToString().Split('\\')[1]; salesInfoList = salesHistory.GetSalesDetails(serialNo, userName); if (salesInfoList.Count > 0) { salesHistory.SalesSerialNumber = salesInfoList[0].SalesSerialNumber; salesHistory.ItemNumber = salesInfoList[0].ItemNumber; salesHistory.SalesOrderNumber = salesInfoList[0].SalesOrderNumber; salesHistory.CustomerName = salesInfoList[0].CustomerName; salesHistory.InvoiceNumber = salesInfoList[0].InvoiceNumber; salesHistory.InvoiceDate = salesInfoList[0].InvoiceDate; } salesHistory.ServiceInfoList = salesHistory.GetServiceDetails(serialNo, userName); ViewData["ServiceInformation"] = salesHistory.ServiceInfoList; TempData.Keep(); } catch (Exception ex) { TempData.Keep(); throw ex; } return(Json(salesHistory)); }
private void btnSalesHistory_Click(object sender, EventArgs e) { SalesHistory salesHistoryForm = new SalesHistory(); salesHistoryForm.parentForm = this.parentForm; salesHistoryForm.Show(); }
public void RemoveSalesHistory(SalesHistory salesHistory) { this.CurrentSalesHistoryCollection.Remove(salesHistory); this.CurrentPaid = 0; this.CurrentChange = 0; this.CurrentSalesHistory = null; this.CurrentAvailableStock = 0; this.CalculateSumTotal(); }
public void Sell() { try { if (SelectedRecord != null) { SalesHistory s = new SalesHistory() { Date = Date, Record = SelectedRecord, SellingPrice = SelectedRecord.SellingPrice, DiscountPrice = total }; if (Client != null && Client.Name != "" && Client.Discount != null) { s.DiscountClient = (float)Client.Discount; s.ClientEmail = Client.Email; s.Client = Client; } if (Deal != null) { s.DiscountDeal = Deal.Discount; } if (Client != null && Client.Email == "") { s.ClientEmail = EmailClient; } DALService.SaleRecord(s); salesHistories.Add(s); if (Client != null && Client.Name != "") { Client.Discount = DALService.CalculateDiscount(Client); DALService.EditDiscountClient(Client, (float)Client.Discount); } OnPropertyChanged(nameof(Client)); Show(); } } catch (DbEntityValidationException ex) { foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors) { MessageBox.Show(validationError.Entry.Entity.ToString()); foreach (DbValidationError err in validationError.ValidationErrors) { MessageBox.Show(err.ErrorMessage + ""); } } } catch (Exception ex1) { MessageBox.Show(ex1.Message); } }
public bool Save(SalesHistory salesHistory) { bool isSaved = false; if (this._slhRepository.Save(salesHistory)) { isSaved = true; } this.PopulateData(); return(isSaved); }
public bool Save(SalesHistory salesHistory) { ValidationHelper validation = new ValidationHelper(); bool isSaved = false; int retry = 0; if (string.IsNullOrEmpty(salesHistory.Id)) { while ((!isSaved) && (retry < 3)) { salesHistory.Id = "000000"; try { this.InsertData(salesHistory); isSaved = true; } catch (SqlException) { retry++; } } } else { while ((!isSaved) && (retry < 3)) { try { this.UpdateData(salesHistory); isSaved = true; } catch (SqlException) { retry++; } } } if (!isSaved) { MessageBox.Show("Terjadi kesalahan program. Silahkan coba beberapa saat lagi.", "Proses Gagal", MessageBoxButton.OK); } this.PopulateData(); return(isSaved); }
private void DeleteData(SalesHistory salesHistory) { using (SqlConnection connection = new SqlConnection(this._connString)) { string deleteSql = @"DELETE FROM dbo.posTbSalesHistory WHERE IdSalesHistory = @SLHIdSalesHistory;"; SqlCommand command = new SqlCommand(deleteSql, connection); command.Parameters.Add("@SLHIdSalesHistory", SqlDbType.Char).Value = salesHistory.Id; connection.Open(); command.ExecuteNonQuery(); } }
private static void AddMovement(ArrayList param, int JournalID, SalesHistory oneObject, string SalesTypeName, string IssuedByName, string PaymentMethodName, float?Debit, float?Credit, int?Account) { DatabaseConnection con = new DatabaseConnection(); param.Clear(); param.Add(new SqlParameter("@JournalID", JournalID)); param.Add(new SqlParameter("@AccountID", Account)); param.Add(new SqlParameter("@Debit", Debit)); param.Add(new SqlParameter("@Credit", Credit)); param.Add(new SqlParameter("@MovementDescription", SalesTypeName + " - T/V: " + oneObject.TicketNumber + " - Issued By : " + IssuedByName + " - " + PaymentMethodName + " - PaxName : " + oneObject.PaxName)); con.ExecSpNone("JournalMovementInsert", param); }
public List <string> FindInvalid(SalesHistory salesHistory) { List <ValidationResult> results = new List <ValidationResult>() { this.Result(salesHistory.SoldItem, " * [Barang dijual] tidak dapat dikosongkan."), this.Result(salesHistory.SoldUnit, " * [Satuan dijual] tidak dapat dikosongkan."), this.Result(salesHistory.SoldQty, " * Nilai minimum [Jumlah dijual] adalah 1.", Enumerable.Range(1, 9), (int)1) }; IEnumerable <string> found = from result in results where (result.IsValid == false) select result.ErrorContent as string; List <string> errorList = found.ToList(); return(errorList); }
public bool Save(SalesHistory salesHistory) { bool isSaved = false; if (this._salesTransactionRepository.Save(salesHistory)) { this.StatusText = string.Format("Histori transaksi untuk transaksi penjualan dengan nomor [{0}] telah disimpan.", salesHistory.ClusterId); isSaved = true; } else { this.StatusText = "Terjadi kesalahan program. Silahkan coba beberapa saat lagi."; } this.Reload("SalesTransaction"); return(isSaved); }
/// <summary> /// Создает данные товара для чека покупателю /// </summary> /// <param name="order">order's data</param> /// <returns>ResponseService<bool></returns> public ResponseService <bool> CreateInvoiceForOrder(SalesHistory order) { var now = DateTime.UtcNow; _logger.LogInformation("Cгенерирован новый заказ"); foreach (var item in order.SalesHistories) { item.Product = _productService .GetProductById(item.Product.Id); // item.Quantity = item.Quantity; var inventoryId = _inventoryService .GetProductById(item.Product.Id).Id; _inventoryService.UpdateQuantities(inventoryId, -item.Quantity); } try { _db.SalesHistories.Add(order); _db.SaveChanges(); return(new ResponseService <bool> { IsSuccess = true, Data = true, Message = "Заказ создан", Time = now }); } catch (Exception e) { return(new ResponseService <bool> { IsSuccess = false, Data = false, Message = e.StackTrace, Time = now }); } }
private void UpdateData(SalesHistory salesHistory) { using (SqlConnection connection = new SqlConnection(this._connString)) { string insertIntoSql = @"UPDATE dbo.posTbSalesHistory SET IdItem = @SLHIdItem, IdUnit = @SLHIdUnit, SoldPrice = @SLHSoldPrice, SoldQty = @SLHSoldQty, SubTotal = @SLHSubTotal, Status = @SLHStatus WHERE IdSalesHistory = @SLHIdSalesHistory;"; SqlCommand command = new SqlCommand(insertIntoSql, connection); command.Parameters.Add("@SLHIdSalesHistory", SqlDbType.Char).Value = salesHistory.Id; command.Parameters.Add("@SLHIdItem", SqlDbType.Char).Value = salesHistory.SoldItem.Id; command.Parameters.Add("@SLHIdUnit", SqlDbType.Char).Value = salesHistory.SoldUnit.Id; command.Parameters.Add("@SLHSoldPrice", SqlDbType.Decimal).Value = salesHistory.SoldPrice; command.Parameters.Add("@SLHSoldQty", SqlDbType.Int).Value = salesHistory.SoldQty; command.Parameters.Add("@SLHSubTotal", SqlDbType.Decimal).Value = salesHistory.SubTotal; command.Parameters.Add("@SLHStatus", SqlDbType.Bit).Value = salesHistory.Status; connection.Open(); command.ExecuteNonQuery(); } }
private void InsertData(SalesHistory salesHistory) { using (SqlConnection connection = new SqlConnection(this._connString)) { string insertIntoSql = @"INSERT INTO dbo.posTbSalesHistory (IdSalesHistory, IdSalesTransaction, IdItem, IdUnit, SoldPrice, SoldQty, SubTotal, Status) VALUES (@SLHIdSalesHistory, @SLHIdSalesTransaction, @SLHIdItem, @SLHIdUnit, @SLHSoldPrice, @SLHSoldQty, @SLHSubTotal, @SLHStatus);"; SqlCommand command = new SqlCommand(insertIntoSql, connection); command.Parameters.Add("@SLHIdSalesHistory", SqlDbType.Char).Value = salesHistory.Id; command.Parameters.Add("@SLHIdSalesTransaction", SqlDbType.Char).Value = salesHistory.ClusterId; command.Parameters.Add("@SLHIdItem", SqlDbType.Char).Value = salesHistory.SoldItem.Id; command.Parameters.Add("@SLHIdUnit", SqlDbType.Char).Value = salesHistory.SoldUnit.Id; command.Parameters.Add("@SLHSoldPrice", SqlDbType.Decimal).Value = salesHistory.SoldPrice; command.Parameters.Add("@SLHSoldQty", SqlDbType.Int).Value = salesHistory.SoldQty; command.Parameters.Add("@SLHSubTotal", SqlDbType.Decimal).Value = salesHistory.SubTotal; command.Parameters.Add("@SLHStatus", SqlDbType.Bit).Value = salesHistory.Status; connection.Open(); command.ExecuteNonQuery(); } }
protected override OpResult _Store(SalesHistory _obj) { if (_obj == null) { return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "SalesHistory object cannot be created as it is null")); } if (Exists(_obj)) { ExecuteNonQuery(GetQuery_UpdateQuery(_obj)); return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj)); } ExecuteNonQuery(GetQuery_InsertQuery(_obj)); if (_obj.SalesHistoryID == null) { _obj.SalesHistoryID = DbMgr.GetLastInsertID(); } _obj.FromDb = true; return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj)); }
public TFormSalesPresenter(AppPresenter appPresenter, TFormSalesView view) : base(view, "TabHeader") { this._appPresenter = appPresenter; this._currentSalesTransaction = new SalesTransaction() { TransactionDate = DateTime.Now, Seller = appPresenter.CurrentLogin, Consumer = appPresenter.FindCustomer(true)[0] }; this._currentSalesHistoryCollection = new ObservableCollection <SalesHistory>(); this._currentSalesHistory = null; this._currentCustomerCollection = new ObservableCollection <Customer>(appPresenter.FindCustomer(true)); this._currentTItemCollection = appPresenter.CurrentTItemCollection; this._currentUnitCollection = null; this._currentAvailableStock = 0; this._currentPaid = 0; this._currentChange = 0; }
public async Task <ActionResult> Add(AcquisitionDto acquisition) { var cart = _context.ShoppingCarts.Where(cart => cart.UserId == acquisition.UserId).ToList(); _context.ShoppingCarts.RemoveRange(cart); foreach (var item in cart) { Product product = _context.Products.Find(item.ProductId); SalesHistory salesHistory = new SalesHistory { UserId = item.UserId, ProductId = item.ProductId, ProductQuantity = item.Quantity, ShopId = acquisition.ShopId, ProductPrice = product.Price * item.Quantity, Date = DateTime.Now }; await _context.SalesHistories.AddAsync(salesHistory); } await _context.SaveChangesAsync(); return(Ok()); }
public override int CalculateUnits(SalesHistory salesHistory, decimal threshold) { throw new NotImplementedException(); }
private void FinalizeOfferAndLog(SellOffer offer, AssetsOwner buyer) { offer.FinalizeOffer(buyer); SalesHistory.AddTodaySaleData(offer.Commodity, offer.Ammount, offer.PricePerPiece); }
private DbUpdateStatement GetQuery_UpdateQuery(SalesHistory _obj) { return(DbMgr.CreateUpdateClause("SalesHistory", GetFields(_obj), "SalesHistoryID", _obj.SalesHistoryID)); }
private DbInsertStatement GetQuery_InsertQuery(SalesHistory _obj) { Dictionary <string, DbFieldEntry> fields = GetFields(_obj); return(DbMgr.CreateInsertClause("SalesHistory", fields)); }
public ActionResult Create([Bind(Include = "TblId,Id,ClothTypeId,ProductName,ProductDetail,Price,Size,Quantity,SouldOuteDate")] SalesHistory inventory) { if (ModelState.IsValid) { //adding process here!!! SalesHistory inv = new SalesHistory(); inv.TblId = inventory.TblId; inv.Id = inventory.Id; inv.ClothTypeId = inventory.ClothTypeId; inv.ProductName = inventory.ProductName; inv.ProductDetail = inventory.ProductDetail; inv.Price = inventory.Price; inv.Size = inventory.Size; inv.Quantity = inventory.Quantity; inv.SouldOuteDate = DateTime.Now; db.Inventories.Add(inv); db.SaveChanges(); // updat table of product///// if (inv.Size.Equals("XS")) { int NowOnStock = db.Products.Where(s => s.pId.Equals(inventory.Id)).Take(1).Single().XS; int Quantity = inventory.Quantity; int result = NowOnStock - Quantity; var content = db.Products.Where(s => s.pId.Equals(inventory.Id)).Take(1).Single(); content.XS = result; db.Entry(content).State = EntityState.Modified; db.SaveChanges(); } if (inventory.Size.Equals("S")) { int NowOnStock = db.Products.Where(m => m.pId.Equals(inventory.Id)).Take(1).Single().S; int Quantity = inventory.Quantity; int result = NowOnStock - Quantity; var content = db.Products.Where(s => s.pId.Equals(inventory.Id)).Take(1).Single(); content.S = result; db.Entry(content).State = EntityState.Modified; db.SaveChanges(); } if (inventory.Size.Equals("M")) { int NowOnStock = db.Products.Where(m => m.pId.Equals(inventory.Id)).Take(1).Single().M; int Quantity = inventory.Quantity; int result = NowOnStock - Quantity; var content = db.Products.Where(s => s.pId.Equals(inventory.Id)).Take(1).Single(); content.M = result; db.Entry(content).State = EntityState.Modified; db.SaveChanges(); } if (inventory.Size.Equals("L")) { int NowOnStock = db.Products.Where(m => m.pId.Equals(inventory.Id)).Take(1).Single().L; int Quantity = inventory.Quantity; int result = NowOnStock - Quantity; var content = db.Products.Where(s => s.pId.Equals(inventory.Id)).Take(1).Single(); content.L = result; db.Entry(content).State = EntityState.Modified; db.SaveChanges(); } if (inventory.Size.Equals("XL")) { int NowOnStock = db.Products.Where(m => m.pId.Equals(inventory.Id)).Take(1).Single().XL; int Quantity = inventory.Quantity; int result = NowOnStock - Quantity; var content = db.Products.Where(s => s.pId.Equals(inventory.Id)).Take(1).Single(); content.XL = result; db.Entry(content).State = EntityState.Modified; db.SaveChanges(); } if (inv.ClothTypeId.Equals("0")) { ModelState.AddModelError("", "Product type is require"); } return(RedirectToAction("Index")); } return(View(inventory)); }
public int Add(SalesHistory history) { return(SalesHistoryServices.salesHistoryDataAccess.Add(history)); }
public abstract decimal CalculatePercent(SalesHistory salesHistory);
public Market(string name, SalesHistory salesHistory) { Name = name; SalesHistory = salesHistory; }
public override decimal CalculatePercent(SalesHistory salesHistory) { throw new NotImplementedException(); }
public void Delete(SalesHistory salesHistory) { this.DeleteData(salesHistory); this.PopulateData(); }
public abstract int CalculateUnits(SalesHistory salesHistory, decimal threshold);
public int Add(SalesHistory salesHistory) { string query = string.Format("INSERT INTO SalesHistory(ProductSaleDate,SellingProduct,ProductPrice,ProductPayment,ProductDiscount,ProductPayable) VALUES('{0}', '{1}', {2}, '{3}', '{4}', '{5}'", salesHistory.ProductSaleDate, salesHistory.SellingProduct, salesHistory.ProductPrice, salesHistory.ProductPayment, salesHistory.ProductDiscount, salesHistory.ProductPayable); return(DataAccess.ExecuteQuery(query)); }
private void FinizeOfferPartiallyAndLog(SellOffer offer, int ammount, AssetsOwner buyer) { offer.FinalizeOfferPartially(buyer, ammount); SalesHistory.AddTodaySaleData(offer.Commodity, ammount, offer.PricePerPiece); }
public void Delete(SalesHistory salesHistory) { this._slhRepository.Delete(salesHistory); this.PopulateData(); }
public BasicSalesHistory(SalesHistory sales) { median = sales.GetMedian(); this.sales = sales.sales.Select(sale => new BasicHistoryItem(sale)).ToList(); }