Пример #1
0
        protected void btn_sure_Click(object sender, EventArgs e)
        {
            Place         place    = this.AddProduct();
            PlaceProvider provider = new PlaceProvider();

            switch (this.OperationFlag)
            {
            case Operation.Add:
                if (this.IsSame() == 1)
                {
                    break;
                }
                if (provider.Insert(place))
                {
                    this.Alert("添加成功!!!");
                    this.TextCancel();
                }
                break;

            case Operation.Update:
                if (provider.Update(place))
                {
                    this.Alert("修改成功!!!");
                    this.BindText();
                }
                break;
            }
        }
Пример #2
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int rowIndex = e.RowIndex;

            Place place = new Place();

            place.Place_id = Convert.ToInt32(this.GridView1.DataKeys[rowIndex].Value);

            PlaceProvider provider = new PlaceProvider();

            if (provider.Delete(place))
            {
                this.Alert("删除成功!!!");

                if (this.txt_Name.Text == "")
                {
                    this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1;
                    this.BindSource(null);
                }
                else
                {
                    this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1;
                    this.BindSource("%" + this.txt_Name.Text + "%");
                }
            }
        }
 /// <summary>
 /// Delete place
 /// </summary>
 /// <param name="place"></param>
 /// <returns></returns>
 public virtual async Task DeletePlace(PlaceProvider place)
 {
     if (place is null)
     {
         throw new ArgumentNullException(nameof(place));
     }
     data.TryRemove(place.PlaceProviderId, out var _);
 }
Пример #4
0
        protected HttpResponseMessage PlaceProviderRegistration(HttpClient client, PlaceProvider pp)
        {
            var body = Newtonsoft.Json.JsonConvert.SerializeObject(pp);

            return(client.PostAsync("PlaceProvider/Register",
                                    new System.Net.Http.StringContent(body, Encoding.UTF8, "application/json")
                                    ).Result);
        }
Пример #5
0
        /// <summary>
        /// Deletes place
        /// </summary>
        /// <param name="place"></param>
        /// <returns></returns>
        public virtual async Task Delete(PlaceProvider place)
        {
            if (place is null)
            {
                throw new ArgumentNullException(nameof(place));
            }

            await redisCacheClient.Db0.HashDeleteAsync($"{configuration["db-prefix"]}{REDIS_KEY_PLACES_OBJECTS}", place.PlaceProviderId);
        }
Пример #6
0
        public MainViewModel()
        {
            // Initialize Data layer
            var fs                          = new MyAccounts.Business.IO.WindowsFileSystem();
            var workingCopy                 = new WorkingCopy(fs, Properties.Settings.Default.WorkingFolder);
            var accountsRepository          = new AccountsRepository(workingCopy);
            var accountCommandRepository    = new AccountCommandRepository(workingCopy);
            var placesRepository            = new PlacesRepository();
            var placeProvider               = PlaceProvider.Load(placesRepository);
            var placeInfoResolver           = new PlaceInfoResolver(placeProvider);
            var operationPatternTransformer = new UnifiedAccountOperationPatternTransformer(placeInfoResolver);
            var operationsRepository        = new OperationsRepository(workingCopy, new CsvAccountOperationManager(), operationPatternTransformer);

            // Initialize Managers
            var operationsManager = new OperationsManager(App.CacheManager, operationsRepository);
            var accountsManager   = new AccountsManager(App.CacheManager, accountsRepository);
            var importManager     = new ImportManager(App.CacheManager, accountCommandRepository, operationsManager);

            // Initialize View Models

            BusyIndicator = new BusyIndicatorViewModel();

            ImportsManagerViewModel = new ImportsManagerViewModel(BusyIndicator, fs, importManager);

            OperationsManagerViewModel = new OperationsManagerViewModel(BusyIndicator, operationsManager, importManager);
            AccountsManagerViewModel   = new AccountsManagerViewModel(BusyIndicator, accountsManager, operationsManager, importManager);
            DashboardViewModel         = new DashboardViewModel(BusyIndicator);
            GmcManager       = new GmcManager(BusyIndicator, App.CacheManager, operationsManager);
            _settingsManager = new SettingsManager(App.CacheManager);

            MessengerInstance.Register <Properties.Settings>(this, OnSettingsUpdated);
            _asyncMessageReceiver = new AsyncMessageReceiver(MessengerInstance);
            _asyncMessageReceiver.RegisterAsync <AccountDataInvalidated>(this, data => Refresh());

            if (!IsInDesignMode)
            {
                LoadCommand    = new AsyncCommand(Load);
                RefreshCommand = new AsyncCommand(Refresh);
            }
            else
            {
                AccountsManagerViewModel.Accounts.Add(
                    new AccountViewModel
                {
                    Name   = "Blaise CC",
                    Status =
                    {
                        Operations            =          7,
                        Balance               = 2541.7345M,
                        LastImportedOperation = "2012-0001"
                    }
                });

                AccountsManagerViewModel.CurrentAccount = AccountsManagerViewModel.Accounts.First();
            }
        }
        /// <summary>
        /// set
        /// </summary>
        /// <param name="place"></param>
        /// <returns></returns>
        public override async Task <PlaceProvider> SetPlaceProvider(PlaceProvider place)
        {
            if (place is null)
            {
                throw new ArgumentNullException(nameof(place));
            }

            data[place.PlaceProviderId] = place;
            return(place);
        }
Пример #8
0
        private void BindSource()
        {
            GoodProvider good = new GoodProvider();

            this.ddl_good.DataSource = good.GetAll();
            this.ddl_good.DataBind();
            PlaceProvider place = new PlaceProvider();

            this.ddl_place.DataSource = place.GetAll();
            this.ddl_place.DataBind();
        }
Пример #9
0
        protected void btn_Result_Click(object sender, EventArgs e)
        {
            Place place = new Place();

            place.Place_num = "%" + this.txt_Name.Text + "%";
            PlaceProvider provider = new PlaceProvider();

            this.ListPager1.RecordCount = provider.GetSize(place);
            this.BindSource(0, "%" + this.txt_Name.Text + "%");
            this.ListPager1.PageChange += new PagerEventHandler(ListPager1_PageChange);
        }
Пример #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         PlaceProvider provider = new PlaceProvider();
         this.ListPager1.RecordCount = provider.GetSize();
         this.BindSource(0, null);
     }
     this.account.Text           = Session["LOGINED"].ToString();
     this.datetime.Text          = this.BindDayWeek();
     this.ListPager1.PageChange += new PagerEventHandler(ListPager1_PageChange);
 }
Пример #11
0
        private void BindText()
        {
            Place place = new Place();

            place.Place_id = Convert.ToInt32(id);
            PlaceProvider provider = new PlaceProvider();
            DataTable     table    = new DataTable();

            table = provider.Select(place);

            this.txt_name.Text           = table.Rows[0]["place_num"].ToString();
            this.ddl_state.SelectedValue = table.Rows[0]["place_state"].ToString();
        }
        public ClassificationStepsContext()
        {
            CsvAccountOperationManager = new CsvAccountOperationManager();
            Transformer = new UnifiedAccountOperationPatternTransformer(
                new PlaceInfoResolver(PlaceProvider.Load(new PlacesRepository())));
            WorkingCopy = new WorkingCopy(new FileSystemAdapter(new MockFileSystem()), @"c:\WorkingCopy");

            AccountCommandRepository = new AccountCommandRepository(WorkingCopy);
            var operationsRepository = new OperationsRepository(WorkingCopy, CsvAccountOperationManager, Transformer);

            var cacheManager = new CacheManager(new NoCache());

            OperationsManager = new OperationsManager(cacheManager, operationsRepository);
            ImportManager     = new ImportManager(cacheManager, AccountCommandRepository, OperationsManager);

            AccountId = Guid.NewGuid();
        }
Пример #13
0
        private int IsSame()
        {
            Place         place    = this.AddProduct();
            PlaceProvider provider = new PlaceProvider();

            place.Place_num = this.txt_name.Text;
            DataTable table = new DataTable();

            table = provider.Select(place);
            if (table.Rows.Count != 0)
            {
                this.Alert("该库位编号已经存在,请重新输入!!!");
                return(1);
            }
            else
            {
                return(0);
            }
        }
Пример #14
0
 /// <summary>
 ///  绑定Place信息的数据源
 /// </summary>
 private void BindSource(int start, string name)
 {
     if (name != null)
     {
         Place place = new Place();
         place.Place_num = name;
         PlaceProvider provider = new PlaceProvider();
         DataTable     table    = provider.Select(place, start, this.ListPager1.PageSize);
         this.GridView1.DataSource = table.DefaultView;
         this.GridView1.DataBind();
     }
     else
     {
         PlaceProvider provider = new PlaceProvider();
         DataTable     table    = provider.GetAll(start, this.ListPager1.PageSize);
         this.GridView1.DataSource = table.DefaultView;
         this.GridView1.DataBind();
     }
 }
Пример #15
0
        /// <summary>
        /// Set place
        /// </summary>
        /// <param name="place"></param>
        /// <returns></returns>
        public virtual async Task <PlaceProvider> SetPlaceProvider(PlaceProvider place)
        {
            if (place is null)
            {
                throw new ArgumentNullException(nameof(place));
            }

            try
            {
                await redisCacheClient.Db0.HashSetAsync($"{configuration["db-prefix"]}{REDIS_KEY_PLACES_OBJECTS}", place.PlaceProviderId.ToString(), place);

                return(place);
            }
            catch (Exception exc)
            {
                logger.LogError(exc, exc.Message);
                throw;
            }
        }
Пример #16
0
        /// <summary>
        /// Registers as place provider
        /// </summary>
        /// <param name="placeProvider"></param>
        /// <returns></returns>
        public async Task <PlaceProvider> Register(PlaceProvider placeProvider)
        {
            if (string.IsNullOrEmpty(placeProvider?.CompanyId))
            {
                throw new Exception("Company trade registry ID has not been entered");
            }
            placeProvider.PlaceProviderId = placeProvider.CompanyId.Trim();
            PlaceProvider place = null;

            try
            {
                place = await GetPlaceProvider(placeProvider.PlaceProviderId);
            }
            catch (Exception exc) { logger.LogError(exc, exc.Message); }
            if (place != null)
            {
                throw new Exception("Place provider with the specified company id already exists. Please contact administrator");
            }
            return(await SetPlaceProvider(placeProvider));
        }
Пример #17
0
        /// <summary>
        /// List by pp
        /// </summary>
        /// <param name="placeProvider"></param>
        /// <returns></returns>
        public virtual async Task <List <PlaceProduct> > ListPlaceProductByPlaceProvider(PlaceProvider placeProvider)
        {
            var ret = new List <PlaceProduct>();

            foreach (var id in (await redisCacheClient.Db0.SetMembersAsync <string>($"{configuration["db-prefix"]}{REDIS_KEY_PRODUCT_PLACES_BY_PP}_{placeProvider.PlaceProviderId}")))
            {
                var item = await GetPlaceProduct(id);

                if (item != null)
                {
                    ret.Add(item);
                }
            }
            return(ret);
        }
Пример #18
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex = Convert.ToInt32(e.CommandArgument);

            if (e.CommandName.Equals("warehousing"))
            {
                Good good = new Good();
                good.Good_name = this.GridView1.Rows[rowIndex].Cells[0].Text;
                ////good.Good_code = this.GridView1.Rows[rowIndex].Cells[3].Text;
                GoodProvider goodProvider = new GoodProvider();
                DataTable    table        = goodProvider.Select(good);
                if (table.Rows.Count != 0)
                {
                    Warehouse      warehouse      = new Warehouse();
                    Warehouse_info warehouse_info = new Warehouse_info();
                    warehouse.Good_id        = Convert.ToInt32(table.Rows[0]["good_id"]);
                    warehouse.Warehouse_type = "入库";
                    warehouse_info.Good_id   = Convert.ToInt32(table.Rows[0]["good_id"]);
                    WarehouseInfoProvider warehouseInfoProvider = new WarehouseInfoProvider();
                    table = warehouseInfoProvider.Select(warehouse_info);
                    WarehouseProvider warehouseProvider = new WarehouseProvider();
                    Shop shop = new Shop();
                    shop.Shop_id = Convert.ToInt32(this.GridView1.DataKeys[rowIndex].Value);
                    ShopProvider shopProvider = new ShopProvider();
                    if (table.Rows.Count != 0)
                    {
                        warehouse_info.Warehouse_info_number = Convert.ToInt32(this.GridView1.Rows[rowIndex].Cells[5].Text);
                        warehouse.Warehouse_number           = Convert.ToInt32(this.GridView1.Rows[rowIndex].Cells[5].Text);
                        warehouse.Order_id               = Convert.ToInt32(id);
                        warehouse.Warehouse_operators    = Session["LOGINED"].ToString();
                        warehouse.Warehouse_time         = Convert.ToDateTime(DateTime.Now.ToString("HH:mm:ss"));
                        warehouse_info.Warehouse_info_id = Convert.ToInt32(table.Rows[0]["warehouse_info_id"]);
                        if (warehouseInfoProvider.Update(warehouse_info.Warehouse_info_number, warehouse_info.Warehouse_info_id))
                        {
                            if (shopProvider.Delete(shop))
                            {
                                if (warehouseProvider.Insert(warehouse))
                                {
                                    this.Alert("入库成功!");
                                    Shop shop1 = new Shop();
                                    shop.Contrac_id = Convert.ToInt32(id);
                                    ContractShopProvider provider = new ContractShopProvider();
                                    this.ListPager1.RecordCount = provider.GetSize(shop1);
                                    this.BindSource(0);
                                    if (this.ListPager1.RecordCount > 0)
                                    {
                                        ContractProvider contractProvider = new ContractProvider();
                                        contractProvider.Update(id, "已部分收货");
                                    }
                                    else
                                    {
                                        ContractProvider contractProvider = new ContractProvider();
                                        contractProvider.Update(id, "已全部收货");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        warehouse_info.Warehouse_id          = warehouseProvider.GetSize() + 1;
                        warehouse_info.Warehouse_info_number = Convert.ToInt32(this.GridView1.Rows[rowIndex].Cells[5].Text);
                        warehouse.Warehouse_number           = Convert.ToInt32(this.GridView1.Rows[rowIndex].Cells[5].Text);
                        warehouse.Order_id            = Convert.ToInt32(id);
                        warehouse.Warehouse_operators = Session["LOGINED"].ToString();
                        warehouse.Warehouse_time      = Convert.ToDateTime(DateTime.Now.Date);
                        Place place = new Place();
                        place.Place_state = "空闲";
                        PlaceProvider placeProvider = new PlaceProvider();
                        table = placeProvider.Select(place);
                        warehouse_info.Place_id = Convert.ToInt32(table.Rows[0]["place_id"]);
                        if (warehouseInfoProvider.Insert(warehouse_info))
                        {
                            if (shopProvider.Delete(shop))
                            {
                                if (warehouseProvider.Insert(warehouse))
                                {
                                    this.Alert("入库成功!");
                                    Shop shop1 = new Shop();
                                    shop.Contrac_id = Convert.ToInt32(id);
                                    ContractShopProvider provider = new ContractShopProvider();
                                    this.ListPager1.RecordCount = provider.GetSize(shop1);
                                    this.BindSource(0);
                                    Contract contract = new Contract();
                                    if (this.ListPager1.RecordCount > 0)
                                    {
                                        ContractProvider contractProvider = new ContractProvider();
                                        contractProvider.Update(id, "已部分收货");
                                    }
                                    else
                                    {
                                        ContractProvider contractProvider = new ContractProvider();
                                        contractProvider.Update(id, "已全部收货");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #19
0
 /// <summary>
 /// list by pp
 /// </summary>
 /// <param name="placeProvider"></param>
 /// <returns></returns>
 public override async Task <List <PlaceProduct> > ListPlaceProductByPlaceProvider(PlaceProvider placeProvider)
 {
     return(dataPlaceProduct.Values.Where(p => p.PlaceProviderId == placeProvider.PlaceProviderId).ToList());
 }
Пример #20
0
        public async Task <ActionResult <PlaceProvider> > UpdatePP([FromBody] PlaceProvider placeProvider)
        {
            try
            {
                if (placeProvider is null)
                {
                    throw new ArgumentNullException(nameof(placeProvider));
                }

                if (string.IsNullOrEmpty(placeProvider.PlaceProviderId))
                {
                    throw new Exception("Invalid data has been received");
                }
                if (string.IsNullOrEmpty(placeProvider.MainContact))
                {
                    throw new Exception("Place provide your name in the registration form");
                }
                if (string.IsNullOrEmpty(placeProvider.MainEmail) || !placeProvider.MainEmail.IsValidEmail())
                {
                    throw new Exception("Place provide valid main email");
                }
                placeProvider.PrivatePhone = placeProvider.PrivatePhone.FormatPhone();
                if (string.IsNullOrEmpty(placeProvider.PrivatePhone) || !placeProvider.PrivatePhone.IsValidPhoneNumber())
                {
                    throw new Exception("Place provide valid contact phone number in form +421 907 000 000");
                }

                var toUpdate = await placeProviderRepository.GetPlaceProvider(placeProvider.PlaceProviderId);

                if (toUpdate == null)
                {
                    throw new Exception("Place provider has not been found");
                }

                if (!string.IsNullOrEmpty(placeProvider.CompanyId))
                {
                    toUpdate.CompanyId = placeProvider.CompanyId;
                }
                if (!string.IsNullOrEmpty(placeProvider.CompanyName))
                {
                    toUpdate.CompanyName = placeProvider.CompanyName;
                }
                if (!string.IsNullOrEmpty(placeProvider.Country))
                {
                    toUpdate.Country = placeProvider.Country;
                }
                if (!string.IsNullOrEmpty(placeProvider.CSS))
                {
                    toUpdate.CSS = placeProvider.CSS;
                }
                if (!string.IsNullOrEmpty(placeProvider.Logo))
                {
                    toUpdate.Logo = placeProvider.Logo;
                }
                if (!string.IsNullOrEmpty(placeProvider.MainContact))
                {
                    toUpdate.MainContact = placeProvider.MainContact;
                }
                if (!string.IsNullOrEmpty(placeProvider.MainEmail))
                {
                    toUpdate.MainEmail = placeProvider.MainEmail;
                }
                if (!string.IsNullOrEmpty(placeProvider.PrivatePhone))
                {
                    toUpdate.PrivatePhone = placeProvider.PrivatePhone;
                }
                if (!string.IsNullOrEmpty(placeProvider.PublicEmail))
                {
                    toUpdate.PublicEmail = placeProvider.PublicEmail;
                }
                if (!string.IsNullOrEmpty(placeProvider.PublicPhone))
                {
                    toUpdate.PublicPhone = placeProvider.PublicPhone;
                }
                if (!string.IsNullOrEmpty(placeProvider.VAT))
                {
                    toUpdate.VAT = placeProvider.VAT;
                }
                if (!string.IsNullOrEmpty(placeProvider.Web))
                {
                    toUpdate.Web = placeProvider.Web;
                }
                if (!string.IsNullOrEmpty(placeProvider.SupportEmail))
                {
                    toUpdate.SupportEmail = placeProvider.SupportEmail;
                }
                if (!string.IsNullOrEmpty(placeProvider.SupportName))
                {
                    toUpdate.SupportName = placeProvider.SupportName;
                }
                if (!string.IsNullOrEmpty(placeProvider.SupportPhone))
                {
                    toUpdate.SupportPhone = placeProvider.SupportPhone;
                }

                return(Ok(await placeProviderRepository.SetPlaceProvider(toUpdate)));
            }
            catch (ArgumentException exc)
            {
                logger.LogError(exc.Message);
                return(BadRequest(new ProblemDetails()
                {
                    Detail = exc.Message
                }));
            }
            catch (Exception exc)
            {
                logger.LogError(exc, exc.Message);
                return(BadRequest(new ProblemDetails()
                {
                    Detail = exc.Message
                }));
            }
        }
Пример #21
0
        public async Task <ActionResult <PlaceProvider> > Register([FromBody] PlaceProvider testingPlaceProvider)
        {
            try
            {
                if (testingPlaceProvider is null)
                {
                    throw new ArgumentNullException(nameof(testingPlaceProvider));
                }

                if (string.IsNullOrEmpty(testingPlaceProvider.MainContact))
                {
                    throw new Exception("Place provide your name in the registration form");
                }
                if (string.IsNullOrEmpty(testingPlaceProvider.MainEmail) || !testingPlaceProvider.MainEmail.IsValidEmail())
                {
                    throw new Exception("Place provide valid main email");
                }
                testingPlaceProvider.PrivatePhone = testingPlaceProvider.PrivatePhone.FormatPhone();
                if (string.IsNullOrEmpty(testingPlaceProvider.PrivatePhone) || !testingPlaceProvider.PrivatePhone.IsValidPhoneNumber())
                {
                    throw new Exception("Place provide valid contact phone number in form +421 907 000 000");
                }
                if (!string.IsNullOrEmpty(configuration["MaxPlaceProviders"]))
                {
                    if (int.TryParse(configuration["MaxPlaceProviders"], out var limit))
                    {
                        var list = await placeProviderRepository.ListPublic();

                        if (limit <= list.Count())
                        {
                            throw new Exception("Place provider limit has been reached");
                        }
                    }
                }
                var ret = await placeProviderRepository.Register(testingPlaceProvider);

                if (ret != null)
                {
                    try
                    {
                        await userRepository.Invite(new Invitation()
                        {
                            CompanyName       = testingPlaceProvider.CompanyName,
                            Email             = testingPlaceProvider.MainEmail,
                            InvitationMessage = "Registrácia správcu odberných miest",
                            InvitationTime    = DateTimeOffset.Now,
                            InviterName       = "System administrator",
                            Name            = testingPlaceProvider.MainContact,
                            Phone           = testingPlaceProvider.PrivatePhone,
                            PlaceProviderId = ret.PlaceProviderId,
                            Status          = InvitationStatus.Invited,
                        });
                    }
                    catch (Exception exc)
                    {
                        logger.LogInformation(exc.Message);
                        // user exists
                    }
                }
                return(Ok(ret));
            }
            catch (ArgumentException exc)
            {
                logger.LogError(exc.Message);
                return(BadRequest(new ProblemDetails()
                {
                    Detail = exc.Message
                }));
            }
            catch (Exception exc)
            {
                logger.LogError(exc, exc.Message);
                return(BadRequest(new ProblemDetails()
                {
                    Detail = exc.Message
                }));
            }
        }