private void OnSearch() { PurchaseManager purchaseManager = new PurchaseManager(); PurchaseOrderList.Clear(); for (Iterator i = purchaseManager.searchPurchaseOrders(SearchPurchaseByOderNo).iterator(); i.hasNext();) { PurchaseInfo purchaseInfo = (PurchaseInfo)i.next(); PurchaseInfoNJ purchaseInfoNJ = new PurchaseInfoNJ(); purchaseInfoNJ.OrderNo = purchaseInfo.getOrderNo(); purchaseInfoNJ.StatusId = purchaseInfo.getStatusId(); purchaseInfoNJ.Remarks = purchaseInfo.getRemarks(); SupplierInfo supplierInfo = new SupplierInfo(); SupplierInfoNJ supplierInfoNJ = new SupplierInfoNJ(); supplierInfoNJ.ProfileInfoNJ.Id = purchaseInfo.getSupplierInfo().getProfileInfo().getId(); supplierInfoNJ.ProfileInfoNJ.FirstName = purchaseInfo.getSupplierInfo().getProfileInfo().getFirstName(); supplierInfoNJ.ProfileInfoNJ.LastName = purchaseInfo.getSupplierInfo().getProfileInfo().getLastName(); purchaseInfoNJ.SupplierInfoNJ = supplierInfoNJ; PurchaseOrderList.Add(purchaseInfoNJ); } }
//constructor public ManagePurchaseOrderList() { //loading purchase list PurchaseManager purchaseManager = new PurchaseManager(); for (Iterator i = purchaseManager.getAllPurchaseOrders().iterator(); i.hasNext();) { PurchaseInfo purchaseInfo = (PurchaseInfo)i.next(); PurchaseInfoNJ purchaseInfoNJ = new PurchaseInfoNJ(); purchaseInfoNJ.OrderNo = purchaseInfo.getOrderNo(); purchaseInfoNJ.StatusId = purchaseInfo.getStatusId(); purchaseInfoNJ.Remarks = purchaseInfo.getRemarks(); for (Iterator j = purchaseInfo.getProductList().iterator(); j.hasNext();) { ProductInfo productInfo = (ProductInfo)j.next(); ProductInfoNJ productInfoNJ = new ProductInfoNJ(); productInfoNJ.Id = productInfo.getId(); productInfoNJ.Name = productInfo.getName(); productInfoNJ.Code = productInfo.getCode(); productInfoNJ.UnitPrice = productInfo.getUnitPrice(); productInfoNJ.Quantity = productInfo.getQuantity(); purchaseInfoNJ.ProductList.Add(productInfoNJ); } SupplierInfo supplierInfo = new SupplierInfo(); SupplierInfoNJ supplierInfoNJ = new SupplierInfoNJ(); supplierInfoNJ.ProfileInfoNJ.Id = purchaseInfo.getSupplierInfo().getProfileInfo().getId(); supplierInfoNJ.ProfileInfoNJ.FirstName = purchaseInfo.getSupplierInfo().getProfileInfo().getFirstName(); supplierInfoNJ.ProfileInfoNJ.LastName = purchaseInfo.getSupplierInfo().getProfileInfo().getLastName(); purchaseInfoNJ.SupplierInfoNJ = supplierInfoNJ; PurchaseOrderList.Add(purchaseInfoNJ); } }
/* * This method will search supplier info * @author A.K.M. Nazmul Islam on 30th january 2016 */ private void OnSearch() { SupplierManager supplierManager = new SupplierManager(); SupplierList.Clear(); for (Iterator i = supplierManager.searchSuppliers(SearchSupplierByPhone).iterator(); i.hasNext();) { SupplierInfo supplierInfo = (SupplierInfo)i.next(); SupplierInfoNJ supplierInfoNJ = new SupplierInfoNJ(); supplierInfoNJ.ProfileInfoNJ.Id = supplierInfo.getProfileInfo().getId(); supplierInfoNJ.ProfileInfoNJ.FirstName = supplierInfo.getProfileInfo().getFirstName(); supplierInfoNJ.ProfileInfoNJ.LastName = supplierInfo.getProfileInfo().getLastName(); supplierInfoNJ.ProfileInfoNJ.Phone = supplierInfo.getProfileInfo().getPhone(); supplierInfoNJ.ProfileInfoNJ.Fax = supplierInfo.getProfileInfo().getFax(); supplierInfoNJ.ProfileInfoNJ.Email = supplierInfo.getProfileInfo().getEmail(); supplierInfoNJ.ProfileInfoNJ.Website = supplierInfo.getProfileInfo().getWebsite(); supplierInfoNJ.Remarks = supplierInfo.getRemarks(); SupplierList.Add(supplierInfoNJ); } }
//constructor public ManageSupplierList() { //loading supplier list SupplierManager supplierManager = new SupplierManager(); for (Iterator i = supplierManager.getAllSuppliers().iterator(); i.hasNext();) { SupplierInfo supplierInfo = (SupplierInfo)i.next(); SupplierInfoNJ supplierInfoNJ = new SupplierInfoNJ(); supplierInfoNJ.ProfileInfoNJ.Id = supplierInfo.getProfileInfo().getId(); supplierInfoNJ.ProfileInfoNJ.FirstName = supplierInfo.getProfileInfo().getFirstName(); supplierInfoNJ.ProfileInfoNJ.LastName = supplierInfo.getProfileInfo().getLastName(); supplierInfoNJ.ProfileInfoNJ.Phone = supplierInfo.getProfileInfo().getPhone(); supplierInfoNJ.ProfileInfoNJ.Fax = supplierInfo.getProfileInfo().getFax(); supplierInfoNJ.ProfileInfoNJ.Email = supplierInfo.getProfileInfo().getEmail(); supplierInfoNJ.ProfileInfoNJ.Website = supplierInfo.getProfileInfo().getWebsite(); supplierInfoNJ.Remarks = supplierInfo.getRemarks(); SupplierList.Add(supplierInfoNJ); } }
//constructor public ManagePurchaseOrder() { //loading purchase list on left panel PurchaseManager purchaseManager = new PurchaseManager(); for (Iterator i = purchaseManager.getAllPurchaseOrders().iterator(); i.hasNext();) { PurchaseInfo purchaseInfo = (PurchaseInfo)i.next(); PurchaseInfoNJ purchaseInfoNJ = new PurchaseInfoNJ(); //We will display order no in grid view on left panel purchaseInfoNJ.OrderNo = purchaseInfo.getOrderNo(); //right now after clicking on item on left panel purchase info is again retrived from the database //so we can ignore rest of the part right now if required. purchaseInfoNJ.StatusId = purchaseInfo.getStatusId(); purchaseInfoNJ.Remarks = purchaseInfo.getRemarks(); for (Iterator j = purchaseInfo.getProductList().iterator(); j.hasNext();) { ProductInfo productInfo = (ProductInfo)j.next(); ProductInfoNJ productInfoNJ = new ProductInfoNJ(); productInfoNJ.Id = productInfo.getId(); productInfoNJ.Name = productInfo.getName(); productInfoNJ.Code = productInfo.getCode(); productInfoNJ.UnitPrice = productInfo.getUnitPrice(); productInfoNJ.Quantity = productInfo.getQuantity(); purchaseInfoNJ.ProductList.Add(productInfoNJ); } SupplierInfo supplierInfo = new SupplierInfo(); SupplierInfoNJ supplierInfoNJ = new SupplierInfoNJ(); supplierInfoNJ.ProfileInfoNJ.Id = purchaseInfo.getSupplierInfo().getProfileInfo().getId(); supplierInfoNJ.ProfileInfoNJ.FirstName = purchaseInfo.getSupplierInfo().getProfileInfo().getFirstName(); supplierInfoNJ.ProfileInfoNJ.LastName = purchaseInfo.getSupplierInfo().getProfileInfo().getLastName(); purchaseInfoNJ.SupplierInfoNJ = supplierInfoNJ; PurchaseOrderList.Add(purchaseInfoNJ); } //Setting a default random Order No for Purchase Info PurchaseInfoNJ.OrderNo = Guid.NewGuid().ToString().ToUpper();; }
/* * This method will display selected purchase info * @author nazmul hasan on 26th january 2016 */ public void OnSelectPurchaseOrderEvent(PurchaseInfoNJ purchaseInfoNJ) { PurchaseManager purchaseManager = new PurchaseManager(); ResultEvent resultEvent = purchaseManager.getPurchaseOrderInfo(purchaseInfoNJ.OrderNo); if (resultEvent.getResponseCode() == Responses.RESPONSE_CODE_SUCCESS) { PurchaseInfo purchaseInfo = (PurchaseInfo)resultEvent.getResult(); PurchaseInfoNJ tempPurchaseInfoNJ = new PurchaseInfoNJ(); tempPurchaseInfoNJ.OrderNo = purchaseInfo.getOrderNo(); tempPurchaseInfoNJ.StatusId = purchaseInfo.getStatusId(); tempPurchaseInfoNJ.Remarks = purchaseInfo.getRemarks(); for (Iterator j = purchaseInfo.getProductList().iterator(); j.hasNext();) { ProductInfo productInfo = (ProductInfo)j.next(); ProductInfoNJ productInfoNJ = new ProductInfoNJ(); productInfoNJ.Id = productInfo.getId(); productInfoNJ.Name = productInfo.getName(); productInfoNJ.Code = productInfo.getCode(); productInfoNJ.UnitPrice = productInfo.getUnitPrice(); productInfoNJ.Quantity = productInfo.getQuantity(); tempPurchaseInfoNJ.ProductList.Add(productInfoNJ); } SupplierInfo supplierInfo = new SupplierInfo(); SupplierInfoNJ supplierInfoNJ = new SupplierInfoNJ(); supplierInfoNJ.ProfileInfoNJ.Id = purchaseInfo.getSupplierInfo().getProfileInfo().getId(); supplierInfoNJ.ProfileInfoNJ.FirstName = purchaseInfo.getSupplierInfo().getProfileInfo().getFirstName(); supplierInfoNJ.ProfileInfoNJ.LastName = purchaseInfo.getSupplierInfo().getProfileInfo().getLastName(); tempPurchaseInfoNJ.SupplierInfoNJ = supplierInfoNJ; PurchaseInfoNJ = tempPurchaseInfoNJ; } else { MessageBox.Show(resultEvent.getMessage()); } }
/* * This method will select a supplier from left panel and update reference of currently selected * supplier info * @author nazmul hasan on 5th january 2016 */ public void OnSelectSupplierEvent(SupplierInfoNJ supplierInfoNJ) { SupplierInfoNJ = supplierInfoNJ; }
/* * This method will reset supplier info * @author nazmul hasan on 5th january 2016 */ private void OnReset() { SupplierInfoNJ = new SupplierInfoNJ(); }
/* * This method will add/update a supplier * @author nazmul hasan on 5th january 2016 */ private void OnAdd() { if (!ValidateSupplier()) { MessageBox.Show(ErrorMessage); return; } ProfileInfo profileInfo = new ProfileInfo(); profileInfo.setId(SupplierInfoNJ.ProfileInfoNJ.Id); profileInfo.setFirstName(SupplierInfoNJ.ProfileInfoNJ.FirstName); profileInfo.setLastName(SupplierInfoNJ.ProfileInfoNJ.LastName); profileInfo.setEmail(SupplierInfoNJ.ProfileInfoNJ.Email); profileInfo.setPhone(SupplierInfoNJ.ProfileInfoNJ.Phone); profileInfo.setFax(SupplierInfoNJ.ProfileInfoNJ.Fax); profileInfo.setWebsite(SupplierInfoNJ.ProfileInfoNJ.Website); SupplierInfo supplierInfo = new SupplierInfo(); supplierInfo.setProfileInfo(profileInfo); SupplierManager supplierManager = new SupplierManager(); SupplierInfoNJ supplierInfoNJ = new SupplierInfoNJ(); supplierInfoNJ.ProfileInfoNJ.Id = SupplierInfoNJ.ProfileInfoNJ.Id; supplierInfoNJ.ProfileInfoNJ.FirstName = SupplierInfoNJ.ProfileInfoNJ.FirstName; supplierInfoNJ.ProfileInfoNJ.LastName = SupplierInfoNJ.ProfileInfoNJ.LastName; supplierInfoNJ.ProfileInfoNJ.Email = SupplierInfoNJ.ProfileInfoNJ.Email; supplierInfoNJ.ProfileInfoNJ.Phone = SupplierInfoNJ.ProfileInfoNJ.Phone; supplierInfoNJ.ProfileInfoNJ.Fax = SupplierInfoNJ.ProfileInfoNJ.Fax; supplierInfoNJ.ProfileInfoNJ.Website = SupplierInfoNJ.ProfileInfoNJ.Website; supplierInfoNJ.Remarks = supplierInfo.getRemarks(); ResultEvent resultEvent = new ResultEvent(); if (SupplierInfoNJ.ProfileInfoNJ.Id > 0) { resultEvent = supplierManager.updateSupplier(supplierInfo); } else { resultEvent = supplierManager.createSupplier(supplierInfo); } if (resultEvent.getResponseCode() == Responses.RESPONSE_CODE_SUCCESS) { if (SupplierInfoNJ.ProfileInfoNJ.Id > 0) { for (int counter = 0; counter < SupplierList.Count; counter++) { SupplierInfoNJ tempSupplierInfoNJ = SupplierList.ElementAt(counter); if (tempSupplierInfoNJ.ProfileInfoNJ.Id == SupplierInfoNJ.ProfileInfoNJ.Id) { SupplierList.RemoveAt(counter); SupplierList.Insert(counter, supplierInfoNJ); } } } else { SupplierInfo responseSupplierInfo = (SupplierInfo)resultEvent.getResult(); SupplierInfoNJ.ProfileInfoNJ.Id = responseSupplierInfo.getProfileInfo().getId(); supplierInfoNJ.ProfileInfoNJ.Id = SupplierInfoNJ.ProfileInfoNJ.Id; if (SupplierList.Count == 0) { SupplierList.Add(supplierInfoNJ); } else { SupplierList.Insert(0, supplierInfoNJ); } } } MessageBox.Show(resultEvent.getMessage()); //resetting supplier info fields OnReset(); }