public void SavePurchase() { if (GetTable().Rows.Count <= 0) { return; } if (m_UIControl.cb_vendorName.SelectedIndex < 0) { m_UIControl.lbl_vendorError.Text = "Please select vendor!"; return; } var vendorId = DataService.GetVendorDataController().GetByName(m_UIControl.cb_vendorName.Text.Trim()).ID; string productIds = string.Empty; string productQuantities = string.Empty; string buyingPrices = string.Empty; string discounts = string.Empty; int i = 0; for (i = 0; i < GetTable().Rows.Count - 1; ++i) { productIds += int.Parse(GetTable().Rows[i].Cells["PurchaseTable_ProductId"].Value.ToString()) + ","; buyingPrices += double.Parse(GetTable().Rows[i].Cells["PurchaseTable_PurchasePrice"].Value.ToString()) + ","; productQuantities += int.Parse(GetTable().Rows[i].Cells["PurchaseTable_Quantity"].Value.ToString()) + ","; discounts += int.Parse(GetTable().Rows[i].Cells["PurchaseTable_DiscountRate"].Value.ToString()) + ","; } productIds += int.Parse(GetTable().Rows[i].Cells["PurchaseTable_ProductId"].Value.ToString()); buyingPrices += double.Parse(GetTable().Rows[i].Cells["PurchaseTable_PurchasePrice"].Value.ToString()); productQuantities += int.Parse(GetTable().Rows[i].Cells["PurchaseTable_Quantity"].Value.ToString()); discounts += int.Parse(GetTable().Rows[i].Cells["PurchaseTable_DiscountRate"].Value.ToString()); PurchasePost purchasePost = new PurchasePost { PurchaseDateTime = m_UIControl.purchase_dateTime.Value, VendorID = vendorId, ProductIDs = productIds, ProductQuantities = productQuantities, BuyingPrices = buyingPrices, Discounts = discounts }; var purchase = DataService.GetPurchaseDataController().Post(purchasePost); //Update stock details UpdateStockDetails(); if (purchase == null) { MessageBox.Show("Purchase entry failed! Please try saving again."); return; } MessageBox.Show("Purchase entry saved successfully!"); ResetUIControls(); Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.PURCHASE, purchase.ID); EventBroadcaster.Get().BroadcastEvent(e); }
private void HandleEvent_NewEntryAdded(Event_NewEntryAdded e) { DBEntityType entityType = e.GetEntityType(); if (entityType == DBEntityType.CUSTOMER) { m_Controller.InitializeComboBox_CustomerName(); } }
private void HandleEvent_NewEntryAdded(Event_NewEntryAdded e) { DBEntityType entityType = e.GetEntityType(); if (entityType == DBEntityType.VENDOR) { AddVendorToTable(e.GetID()); } }
private void HandleEvent_NewEntryAdded(Event_NewEntryAdded e) { var addedEntityType = e.GetEntityType(); if (addedEntityType == DBEntityType.CUSTOMER) { var customer = DataService.GetCustomerDataController().Get(e.GetID()); m_Controller.AddCustomerNameToSearchBox(customer.Name); } }
private void HandleEvent_NewEntryAdded(Event_NewEntryAdded e) { DBEntityType entityType = e.GetEntityType(); if (entityType == DBEntityType.CATEGORY) { var category = DataService.GetCategoryDataController().Get(e.GetID()); m_Controller.AddCategoryToTable(category); } }
private void HandleEvent_NewEntryAdded(Event_NewEntryAdded e) { DBEntityType entityType = e.GetEntityType(); if (entityType == DBEntityType.VENDOR) { VendorGet vendor = DataService.GetVendorDataController().Get(e.GetID()); m_Controller.AddToComboBox_VendorName(vendor.CompanyName); } }
private void HandleEvent_NewEntryAdded(Event_NewEntryAdded e) { DBEntityType entityType = e.GetEntityType(); int id = e.GetID(); if (entityType == DBEntityType.CATEGORY) { CategoryGet category = DataService.GetCategoryDataController().Get(id); m_Controller.AddCategoryToComboBox(category); } }
private void HandleEvent_NewEntryEvent(Event_NewEntryAdded e) { var entity = e.GetEntityType(); int id = e.GetID(); if (entity == DBEntityType.VENDOR) { m_Controller.OnNewVendorAdded(id); } else if (entity == DBEntityType.PRODUCT) { m_Controller.OnNewProductAdded(id); } }
private void HandleEvent_NewEntryAdded(Event_NewEntryAdded e) { DBEntityType entityType = e.GetEntityType(); int id = e.GetID(); if (entityType == DBEntityType.CUSTOMER) { CustomerGet customer = DataService.GetCustomerDataController().Get(id); m_Controller.AddCustomerToTable(customer); } else if (entityType == DBEntityType.TRANSACTION) { TransactionGet transaction = DataService.GetTransactionDataController().Get(id); m_Controller.UpdateCustomerInTable(transaction.Customer); } }
private void btn_saveCategory_Click(object sender, EventArgs eventArgs) { if (!ValidateUI()) { return; } lbl_CategoryError.Text = string.Empty; string name = tb_categoryName.Text.Trim(); string desc = tb_categoryDescription.Text.Trim(); var category = DataService.GetCategoryDataController().GetByName(name); if (category != null) { lbl_CategoryError.Text = "Category with same name already exists!"; return; } CategoryPost categoryPost = new CategoryPost(); categoryPost.Name = name; categoryPost.Description = desc; m_Category = DataService.GetCategoryDataController().Post(categoryPost); if (m_Category == null) { Assert.Do("Failed to add category!"); DialogResult = DialogResult.Cancel; return; } // broadcast new entry added event Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.CATEGORY, m_Category.ID); EventBroadcaster.Get().BroadcastEvent(e); MessageBox.Show("Category Added successfully!"); ResetAll(); if (!checkBox_AddAnotherCategory.Checked) { DialogResult = DialogResult.OK; Close(); } }
private void HandleEvent_NewEntryAdded(Event_NewEntryAdded e) { DBEntityType entityType = e.GetEntityType(); if (entityType == DBEntityType.PRODUCT) { AddProductToTable(e.GetID()); } else if (entityType == DBEntityType.PURCHASE) { OnPurchaseAdded(e.GetID()); } else if (entityType == DBEntityType.TRANSACTION) { OnTransactionAdded(e.GetID()); } }
public void SaveTransaction() { TransactionPost transactionPost = new TransactionPost { CustomerID = m_TransactionSession.GetCustomer().ID, TransactionDateTime = DateTime.Now, TotalPrice = double.Parse(m_TransactionSession.amountDue), TotalTax = double.Parse(m_TransactionSession.totalTax) }; string productIds = string.Empty; string productQuantity = string.Empty; string buyingPrices = string.Empty; string discounts = string.Empty; foreach (var entry in m_TransactionSession.GetRowEntries()) { var product = entry.Product; productIds += product.ID + ","; productQuantity += entry.Quantity + ","; buyingPrices += product.RetailPrice + ","; discounts += product.Discount + ","; } //Removing last comma transactionPost.ProductIDs = productIds.Substring(0, productIds.Length - 1); transactionPost.ProductQuantity = productQuantity.Substring(0, productQuantity.Length - 1); transactionPost.BuyingPrices = buyingPrices.Substring(0, buyingPrices.Length - 1); transactionPost.Discounts = discounts.Substring(0, discounts.Length - 1); var transaction = DataService.GetTransactionDataController().Post(transactionPost); UpdateCustomerDetails(); UpdateStockDetails(); // fire new transaction added event Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.TRANSACTION, transaction.ID); EventBroadcaster.Get().BroadcastEvent(e); }
public VendorGet AddNewVendor() { if (!ValidateVendorDetails()) { return(null); } VendorPost vendor = new VendorPost(); vendor.CompanyName = m_UIControl.tb_companyName.Text.Trim(); vendor.Address = m_UIControl.tb_address.Text.Trim(); vendor.Email = m_UIControl.tb_email.Text.Trim(); vendor.MobileNumber = m_UIControl.tb_mobileNumber.Text.Trim(); vendor.City = m_UIControl.tb_city.Text.Trim(); vendor.State = m_UIControl.tb_state.Text.Trim(); var vendorGet = DataService.GetVendorDataController().Post(vendor); if (vendorGet == null) { Assert.Do("Failed to add vendor"); return(null); } MessageBox.Show("Vendor Added Successfully"); ResetTextBoxes(); Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.VENDOR, vendorGet.ID); EventBroadcaster.Get().BroadcastEvent(e); if (!m_UIControl.checkBox_AddAnotherVendor.Checked) { m_UIControl.DialogResult = DialogResult.OK; m_UIControl.Close(); } return(vendorGet); }
public void SaveCustomer() { m_UIControl.lbl_customerErrorText.Text = string.Empty; if (!ValidateCustomerDetails()) { return; } CustomerPost customerPost = new CustomerPost(); customerPost.Email = m_UIControl.tb_customerEmail.Text.Trim(); customerPost.Name = m_UIControl.tb_CustomerName.Text.Trim(); customerPost.MobileNumber = m_UIControl.tb_customerMobile.Text.Trim(); customerPost.PendingAmount = 0; m_Customer = DataService.GetCustomerDataController().Post(customerPost); m_UIControl.DialogResult = (m_Customer == null) ? DialogResult.No : DialogResult.Yes; // fire customer added event Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.CUSTOMER, m_Customer.ID); EventBroadcaster.Get().BroadcastEvent(e); }
public bool AddNewProduct() { var UI = m_UIControl; UI.DialogResult = DialogResult.None; UI.lbl_Error.Text = string.Empty; if (!ValidateProductDetails()) { return(false); } string categoryName = UI.cb_Category.Text.Trim(); CategoryGet category = DataService.GetCategoryDataController().GetByName(categoryName); int unit = UI.cb_Unit.SelectedIndex + 1; ProductPost productPost = new ProductPost(); productPost.Name = UI.tb_Name.Text.Trim(); productPost.Barcode = UI.tb_Barcode.Text.Trim(); productPost.Description = UI.tb_Description.Text.Trim(); productPost.Unit = unit; productPost.RetailPrice = int.Parse(UI.tb_RetailPrice.Text.Trim()); productPost.WholeSalePrice = int.Parse(UI.tb_WholeSalePrice.Text.Trim()); productPost.CategoryID = category.ID; productPost.CGST = double.Parse(UI.tb_CGST.Text.Trim()); productPost.SGST = double.Parse(UI.tb_CGST.Text.Trim()); productPost.Discount = double.Parse(UI.tb_SGST.Text.Trim()); productPost.ImagePath = GetImagePath(); m_Product = DataService.GetProductDataController().Post(productPost); if (m_Product == null) { MessageBox.Show(UI, "Failed to Add Product!"); return(false); } // post the Default details StockPost stock = new StockPost(); stock.ProductID = m_Product.ID; stock.AvailableQuantity = 0; stock.TotalQuantity = 0; var stockPost = DataService.GetStockDataController().Post(stock); if (stockPost == null) { MessageBox.Show(UI, "Failed to Add Stock!"); return(false); } // Broadcast NewProductAdded Event Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.PRODUCT, m_Product.ID); EventBroadcaster.Get().BroadcastEvent(e); MessageBox.Show(UI, "Product Added Successfully!"); if (!m_UIControl.checkBox_AddAnotherProduct.Checked) { UI.DialogResult = DialogResult.OK; UI.Close(); } return(true); }