public PurchaseHistoryModel(int systemId, string state, string[] history) : base(systemId, state, null) { Items = new PurchaseItemModel[history.Length]; for (int i = 0; i < Items.Length; i++) { Items[i] = new PurchaseItemModel(history[i]); } }
public void SavePurchaseItemDetails(PurchaseItemModel model) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("@Purchase_Id", model.PurchaseID.ToString()); parameters.Add("@Invoice_Number", model.InvoiceNumber.ToString()); parameters.Add("@SubItemId", model.SubItemID.ToString()); parameters.Add("@Quantity", model.Quantity.ToString()); parameters.Add("@Prise", model.Price.ToString()); parameters.Add("@Total", model.Total.ToString()); parameters.Add("@flag", PurchaseDbConstants.PurchaseItemDetails); _purchaseRepo.Save(parameters); }
public async Task <ActionResult <PurchaseItem> > UpdateReceive(PurchaseItemModel itemModel) { var item = await _db.PurchaseItems .Where(o => o.Id == itemModel.Id) .SingleOrDefaultAsync(); item.ReceivedActualWeight = itemModel.ReceivedActualWeight; item.ReceivedCrates = itemModel.ReceivedCrates; item.ReceivedCratesWeight = itemModel.ReceivedCratesWeight; item.ReceivedDateUtc = DateTime.Now; item.ReceivedFruitGradeType = itemModel.ReceivedFruitGradeType; item.ReceivedNotes = itemModel.ReceivedNotes; item.ReceivedTotalWeight = itemModel.ReceivedTotalWeight; item.ReceivingStatusId = itemModel.ReceivingStatusId; _db.PurchaseItems.Update(item); await _db.SaveChangesAsync(); return(item); }
public PurchaseItemViewModel(PurchaseItemModel items, List <Cateory> categories) { //initialize items and catories }
private void btnSubmit_Click(object sender, EventArgs e) { try { Logger.Info("Payment information save start."); Dictionary <string, string> salesInfo = new Dictionary <string, string>(); int purchaseBillingID = 0; if (toggleBilling.Checked) { Logger.Info("Save purchase information start."); PurchaseModel purchaseModel = new PurchaseModel(); purchaseModel.SupplierID = Convert.ToInt32((cmbFirmName.SelectedItem as DropDown).Value); purchaseModel.ExiseDuty = 0; purchaseModel.GrandTotal = !String.IsNullOrEmpty(txtGrandTotal.Text) ? Convert.ToDouble(txtGrandTotal.Text) : 0; purchaseModel.InvoiceNumber = Convert.ToInt32(txtInvoiceNo.Text); purchaseModel.OnCredit = !String.IsNullOrEmpty(txtCreditAmount.Text) ? Convert.ToDouble(txtCreditAmount.Text) : 0; purchaseModel.Paid = String.IsNullOrEmpty(txtPayAmount.Text) ? 0 : Convert.ToDouble(txtPayAmount.Text); purchaseModel.SubTotal = !String.IsNullOrEmpty(txtAmount.Text) ? Convert.ToDouble(txtAmount.Text) : 0; purchaseModel.Tax = !String.IsNullOrEmpty(txtGst.Text) ? Convert.ToDouble(txtGst.Text) : 0; purchaseModel.Trans_Date = dtpBillingDate.Value; purchaseBillingID = purchaseReciever.SavePurchaseInvoice(purchaseModel); Logger.Info("Save purchase information success."); Logger.Info("Save purchase items information start."); foreach (BillingItemModel item in ovlItems.Objects) { PurchaseItemModel purchaseItemModel = new PurchaseItemModel(); purchaseItemModel.InvoiceNumber = Convert.ToInt32(txtInvoiceNo.Text); purchaseItemModel.Price = item.Rate; purchaseItemModel.Quantity = item.Quantity; purchaseItemModel.PurchaseID = purchaseBillingID; purchaseItemModel.SubItemID = Convert.ToInt32(item.ProductValue); purchaseItemModel.Total = item.Total; purchaseReciever.SavePurchaseItemDetails(purchaseItemModel); } Logger.Info("Save purchase items information success."); } else { Logger.Info("Save sales information start."); // Save sales details SalesModel sales = new SalesModel(); sales.CustomerID = Convert.ToInt32((cmbFirmName.SelectedItem as DropDown).Value); sales.TransactionDate = dtpBillingDate.Value; sales.Amount = !String.IsNullOrEmpty(txtAmount.Text) ? Convert.ToDouble(txtAmount.Text) : 0; sales.Carton = 0; sales.Discount = String.IsNullOrEmpty(txtRound.Text) ? 0 : Convert.ToDouble(txtRound.Text); sales.GrandTotal = !String.IsNullOrEmpty(txtGrandTotal.Text) ? Convert.ToDouble(txtGrandTotal.Text) : 0; sales.GST = !String.IsNullOrEmpty(txtGst.Text) ? Convert.ToDouble(txtGst.Text) : 0; sales.OnCredit = !String.IsNullOrEmpty(txtCreditAmount.Text) ? Convert.ToDouble(txtCreditAmount.Text) : 0; sales.Paid = String.IsNullOrEmpty(txtPayAmount.Text) ? 0 : Convert.ToDouble(txtPayAmount.Text); sales.TransportationID = transportationModel != null ? transportationModel.TransportationID : 0; salesInfo = salesReciever.SaveSales(sales); Logger.Info("Save sales information success."); Logger.Info("Save sales items information start."); // Add sales Items details foreach (BillingItemModel item in ovlItems.Objects) { SalesItemDetailsModel salesDetails = new SalesItemDetailsModel(); salesDetails.InvoiceNumber = Convert.ToInt32(salesInfo.ElementAt(1).Value); salesDetails.SalesID = Convert.ToInt32(salesInfo.ElementAt(0).Value); salesDetails.SubItemID = Convert.ToInt32(item.ProductValue); salesDetails.Quantity = item.Quantity; salesDetails.Rate = item.Rate; salesDetails.Total = item.Total; salesReciever.SaveSalesDetails(salesDetails); Logger.Info(string.Format("Sales item {0} added and amount is {1}.", salesDetails.SubItemID, salesDetails.Total)); } Logger.Info("Save sales items information success."); if (transportationModel != null) { if (!String.IsNullOrEmpty(transportationModel.TEmployeeName) && !String.IsNullOrEmpty(transportationModel.TVehicleNumber)) { Logger.Info("Save tranportation information start."); transportationModel.SalesID = Convert.ToInt32(salesInfo.ElementAt(0).Value); salesReciever.SaveTransportDetails(transportationModel); Logger.Info("Save tranportation information success."); } } } if (paymentTransactionModel != null) { var sales = toggleBilling.Checked ? false : true; if (paymentTransactionModel.AccountID > 0 && paymentTransactionModel.PaymentModeID > 0) { Logger.Info("Payment information save start."); SalesPayment salesPayment = new SalesPayment(); salesPayment.PaymentModeID = paymentTransactionModel.PaymentModeID; salesPayment.TransactionDetailNo = paymentTransactionModel.TransactionNumber; salesPayment.BillingID = sales ? Convert.ToInt32(salesInfo.ElementAt(0).Value) : purchaseBillingID; salesPayment.ToAcc = paymentTransactionModel.AccountID.ToString(); salesPayment.TransactionDate = dtpBillingDate.Value; salesPayment.Description = paymentTransactionModel.Description; salesPayment.InvoieType = sales ? "S" : "P"; salesReciever.SavePaymentDetails(salesPayment); Logger.Info("Payment information save success."); } } ResetItem(); ResetBillingInformation(); ResetItemList(); ResetTransportationDetails(); ResetPaymentMode(); MessageBox.Show("Billing invoice saved successfully.", "Success", MessageBoxButtons.OK); } catch (Exception ex) { Logger.Error("Error in billing invoice submit.", ex); } }