public void SynchronizeCustomersOnepresalers(Action <string, string, double> progressAction, PosUserTypes userType)
        {
            string    res   = "";
            DataTable dt    = null;
            DataTable dtdam = null;

            switch (userType)
            {
            case PosUserTypes.Distributor:
                NavDbController.Current.getCustomersForDistibutor(ref res, ref dtdam);
                break;

            case PosUserTypes.PreSaler:
                NavDbController.Current.getCustomersForPresaler(ref res, ref dtdam);
                break;

            case PosUserTypes.Manager:
                NavDbController.Current.getCustomers(ref res, ref dtdam);
                break;

            case PosUserTypes.Shop:
                NavDbController.Current.getCustomersAll(ref res, ref dtdam);
                break;
            }
            if (!string.IsNullOrEmpty(res))
            {
                throw new PosException(res);
            }

            POSMng.POSMng service = new POSMng.POSMng
            {
                UseDefaultCredentials = false,
                Credentials           = new System.Net.NetworkCredential(PosSetting.Settings_DomainUserName, PosSetting.Settings_DomainPassword, PosSetting.Settings_DomainName),
                Url = PosSetting.Settings_PosServiceUrl
            };
            var cnt = dtdam.Rows.Count;
            int i   = 0;

            foreach (DataRow r in dtdam.Rows)
            {
                i++;
                progressAction(null, "Synchronizing Customers with one presalers", 20 + i * 20.0 / cnt);
                var     customer_no            = r["No_"].ToString();
                decimal balanceAmount          = 0;
                decimal salesBudgetAmount      = 0;
                decimal salesActualAmount      = 0;
                decimal recommendedSalesAmount = 0;
                int     recommendedVisitsMonth = 0;
                service.GetCustomerFinDetails(customer_no, ref balanceAmount, ref salesBudgetAmount, ref salesActualAmount, ref recommendedSalesAmount, ref recommendedVisitsMonth, DateTime.Now.Date);
                DaoController.Current.SyncCustomers(r, balanceAmount, salesBudgetAmount, salesActualAmount, recommendedSalesAmount, recommendedVisitsMonth, null);
                NavDbController.Current.getCustomerShippingAddresses(ref res, customer_no, ref dt);
                if (!string.IsNullOrEmpty(res))
                {
                    throw new PosException(res);
                }
                DaoController.Current.SyncShipToAddress(dt);
            }
        }
        public void SynchronizeCustomersManypresalers(Action <string, string, double> progressAction)
        {
            string    res   = "";
            DataTable dt    = null;
            DataTable dtdam = null;

            NavDbController.Current.getSalesPersonShippingAddresses(ref res, ref dt);
            if (!string.IsNullOrEmpty(res))
            {
                throw new PosException(res);
            }
            DaoController.Current.SyncShipToAddress(dt);
            POSMng.POSMng service = new POSMng.POSMng
            {
                UseDefaultCredentials = false,
                Credentials           = new System.Net.NetworkCredential(PosSetting.Settings_DomainUserName, PosSetting.Settings_DomainPassword, PosSetting.Settings_DomainName),
                Url = PosSetting.Settings_PosServiceUrl
            };
            var cnt = dt.Rows.Count;
            int i   = 0;

            foreach (DataRow r in dt.Rows)
            {
                i++;
                progressAction(null, "Synchronizing Customers with many presalers", 40 + i * 10.0 / cnt);
                var     customer_no            = r["Customer No_"].ToString();
                decimal balanceAmount          = 0;
                decimal salesBudgetAmount      = 0;
                decimal salesActualAmount      = 0;
                decimal recommendedSalesAmount = 0;
                int     recommendedVisitsMonth = 0;
                NavDbController.Current.getCustomer(ref res, customer_no, ref dtdam);
                service.GetCustomerFinDetails(customer_no, ref balanceAmount, ref salesBudgetAmount, ref salesActualAmount, ref recommendedSalesAmount, ref recommendedVisitsMonth, DateTime.Now.Date);
                var r1  = dtdam.Rows[0];
                var cst = DaoController.Current.GetCustomer(r1["No_"].ToString());
                if (cst == null)
                {
                    DaoController.Current.SyncCustomers(r1, balanceAmount, salesBudgetAmount, salesActualAmount, recommendedSalesAmount, recommendedVisitsMonth, r["Visit Week Days"].ToString());
                }
            }
            //Synchronize payment schedules
            NavDbController.Current.getSalesPersonShippingAddressesGrouped(ref res, ref dt);
            if (!string.IsNullOrEmpty(res))
            {
                throw new PosException(res);
            }
        }