Example #1
0
        /*
         * This method will add/update a customer
         * @author nazmul hasan on 5th january 2016
         */
        private void OnAdd()
        {
            if (!ValidateCustomer())
            {
                MessageBox.Show(ErrorMessage);
                return;
            }
            ProfileInfo profileInfo = new ProfileInfo();

            profileInfo.setId(CustomerInfoNJ.ProfileInfoNJ.Id);
            profileInfo.setFirstName(CustomerInfoNJ.ProfileInfoNJ.FirstName);
            profileInfo.setLastName(CustomerInfoNJ.ProfileInfoNJ.LastName);
            profileInfo.setEmail(CustomerInfoNJ.ProfileInfoNJ.Email);
            profileInfo.setPhone(CustomerInfoNJ.ProfileInfoNJ.Phone);
            profileInfo.setFax(CustomerInfoNJ.ProfileInfoNJ.Fax);
            profileInfo.setWebsite(CustomerInfoNJ.ProfileInfoNJ.Website);
            CustomerInfo customerInfo = new CustomerInfo();

            customerInfo.setProfileInfo(profileInfo);
            CustomerManager customerManager = new CustomerManager();

            CustomerInfoNJ customerInfoNJ = new CustomerInfoNJ();

            customerInfoNJ.ProfileInfoNJ.Id        = CustomerInfoNJ.ProfileInfoNJ.Id;
            customerInfoNJ.ProfileInfoNJ.FirstName = CustomerInfoNJ.ProfileInfoNJ.FirstName;
            customerInfoNJ.ProfileInfoNJ.LastName  = CustomerInfoNJ.ProfileInfoNJ.LastName;
            customerInfoNJ.ProfileInfoNJ.Email     = CustomerInfoNJ.ProfileInfoNJ.Email;
            customerInfoNJ.ProfileInfoNJ.Phone     = CustomerInfoNJ.ProfileInfoNJ.Phone;
            customerInfoNJ.ProfileInfoNJ.Fax       = CustomerInfoNJ.ProfileInfoNJ.Fax;
            customerInfoNJ.ProfileInfoNJ.Website   = CustomerInfoNJ.ProfileInfoNJ.Website;

            ResultEvent resultEvent = new ResultEvent();

            if (CustomerInfoNJ.ProfileInfoNJ.Id > 0)
            {
                resultEvent = customerManager.updateCustomer(customerInfo);
            }
            else
            {
                resultEvent = customerManager.createCustomer(customerInfo);
            }
            if (resultEvent.getResponseCode() == Responses.RESPONSE_CODE_SUCCESS)
            {
                if (CustomerInfoNJ.ProfileInfoNJ.Id > 0)
                {
                    for (int counter = 0; counter < CustomerList.Count; counter++)
                    {
                        CustomerInfoNJ tempCustomerInfoNJ = CustomerList.ElementAt(counter);

                        if (tempCustomerInfoNJ.ProfileInfoNJ.Id == CustomerInfoNJ.ProfileInfoNJ.Id)
                        {
                            CustomerList.RemoveAt(counter);
                            CustomerList.Insert(counter, customerInfoNJ);
                        }
                    }
                }
                else
                {
                    CustomerInfo responseCustomerInfo = (CustomerInfo)resultEvent.getResult();
                    CustomerInfoNJ.ProfileInfoNJ.Id = responseCustomerInfo.getProfileInfo().getId();
                    customerInfoNJ.ProfileInfoNJ.Id = CustomerInfoNJ.ProfileInfoNJ.Id;
                    if (CustomerList.Count == 0)
                    {
                        CustomerList.Add(customerInfoNJ);
                    }
                    else
                    {
                        CustomerList.Insert(0, customerInfoNJ);
                    }
                }
            }
            MessageBox.Show(resultEvent.getMessage());
            //reset create Customer fields
            OnReset();
        }
Example #2
0
        /*
         * 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();
        }
Example #3
0
        /// <summary>
        /// Called when Button SendToViewModel is clicked
        /// </summary>
        private void OnAdd()
        {

            ProfileInfo userInfo = new ProfileInfo();
            userInfo.setFirstName(CustomerFirstName);
            userInfo.setLastName(CustomerLastName);
            userInfo.setEmail(CustomerEmail);
            userInfo.setPhone(CustomerPhone);
            userInfo.setFax(CustomerFax);
            userInfo.setWebsite(CustomerWebsite);



            CustomerInfo customerInfo = new CustomerInfo();
            customerInfo.setUserInfo(userInfo);

            CustomerManager customerManager = new CustomerManager();
            customerManager.createCustomer(customerInfo);


            MessageBox.Show("Save Successfully");
        }