public JsonResult Add(FormCollection collection)
        {
            try
            {
                var id   = long.Parse(collection["hdProvinceId"]);
                var name = collection["txtName"];
                var type = collection["txtType"];

                var province = new ProvinceEntity
                {
                    Id   = id,
                    Name = name,
                    Type = type
                };
                var ipl = SingletonIpl.GetInstance <IplProvince>();

                if (id == 0)
                {
                    id = ipl.Insert(province);
                    return(Json(new { status = true, Data = id }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var res = ipl.Update(province);
                    return(Json(new { status = res, Data = res }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = "Lỗi không lưu được tài khoản." }, JsonRequestBehavior.AllowGet));
            }
        }
        public string getLstProvince(string country_id)
        {
            List <ProvinceEntity> lst = new List <ProvinceEntity>();

            _conn.Open();

            //---
            MySqlCommand cmd = new MySqlCommand("GETPROVINCE", _conn.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@I_COUNTRY_ID", "7023A3EE5371681DE054000C29748FC6");

            using (var cursor = cmd.ExecuteReader())
            {
                while (cursor.Read())
                {
                    ProvinceEntity item = new ProvinceEntity(
                        Convert.ToString(cursor["PROVINCE_ID"]),
                        Convert.ToString(cursor["PROVINCE_NAME"]),
                        Convert.ToString(cursor["COUNTRY_NAME"]),
                        Convert.ToString(cursor["SHORT_NAME"]),
                        Convert.ToString(cursor["CUSTOMIZE_NAME"]),
                        Convert.ToString(cursor["DESCRIPTION"]),
                        Convert.ToString(cursor["COUNTRY_ID"]),
                        Convert.ToString(cursor["SORT_ORDER"]));
                    lst.Add(item);
                }
            }
            _conn.Close();

            return(JsonConvert.SerializeObject(lst));
        }
        public JsonResult ListAll()
        {
            try
            {
                var total = 0;
                var obj   = new ProvinceEntity();
                var ipl   = SingletonIpl.GetInstance <IplProvince>();
                var res   = ipl.ListAll();

                if (res != null && res.Count > 0)
                {
                    return(Json(new
                    {
                        status = true,
                        Data = res,
                        totalCount = res.Count
                    }, JsonRequestBehavior.AllowGet));
                }

                return(Json(new
                {
                    status = true,
                    Data = res,
                    totalCount = 0
                }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new
                {
                    status = false
                }, JsonRequestBehavior.AllowGet));
            }
        }
Example #4
0
        private void OnCreateChanage(object sender, EventArgs e)
        {
            ProvinceEntity newEntity = (ProvinceEntity)sender;

            bindingSource1.Add(newEntity);
            bindingSource1.ResetBindings(false);
        }
Example #5
0
        private bool Save()
        {
            if (!IsFieldValueValid())
            {
                return(false);
            }
            bool success = false;

            try
            {
                ProvinceEntity editEntity = PrepareSave();
                int            ret        = ProvinceDal.Save(editEntity, isNew);
                if (ret == -1)
                {
                    MsgBox.Warn("编号已存在,请改为其他的编号。");
                }
                else if (ret == -2)
                {
                    MsgBox.Warn("更新失败,该行已经被其他人删除。");
                }
                else
                {
                    success = true;
                    if (DataSourceChanged != null)
                    {
                        DataSourceChanged(editEntity, null);
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.Warn(ex.Message);
            }
            return(success);
        }
        public ActionResult <Api <ProvinceDTO> > AddProvince(ProvinceEntity province)
        {
            ProvinceDTO dto = _provinceService.save(province);

            Api <ProvinceDTO> result = new Api <ProvinceDTO>(200, dto, "Success", null);

            return(Ok(result));
        }
Example #7
0
        /// <summary>
        /// 检查省份编码是否已存在
        /// </summary>
        /// <param name="dept"></param>
        /// <returns></returns>
        private bool IsProvinceCodeExists(ProvinceEntity Province)
        {
            IMapper map = DatabaseInstance.Instance();
            string  id  = map.ExecuteScalar <string>("select PROV_CODE from PROVINCES where PROV_CODE = @COD",
                                                     new { COD = Province.ProvinceCode });

            return(!string.IsNullOrEmpty(id));
        }
Example #8
0
 private void ShowEditInfo(ProvinceEntity provinceEntity)
 {
     txtCode.Text      = provinceEntity.ProvinceCode;
     txtName.Text      = provinceEntity.ProvinceName;
     txtAliasName.Text = provinceEntity.AliasName;
     txtAreaCode.Text  = provinceEntity.AreaCode;
     txtCapital.Text   = provinceEntity.Capital;
     txtNamePY.Text    = provinceEntity.NamePY;
 }
        private void AddNewProvince_OnExecute()
        {
            var province = new ProvinceEntity();

            province.Validate();
            _entityService.Provinces.Add(province);

            _provinceListViewModel.SelectedItem = _provinceDataModels.Single(p => p.Entity == province);
            _provinceListViewModel.Focus();
        }
Example #10
0
        public async Task <GroupEntity> SetProvince(string chatId, ProvinceEntity province)
        {
            var info = await GetGroupInfo(chatId);

            info.ProvinceName = province.Title;
            info.ProvinceId   = province.Id;
            await _context.SaveChangesAsync();

            return(info);
        }
Example #11
0
        private void SelectCountry_OnExecute(ProvinceEntity province)
        {
            var countrySelectorViewModel = _countrySelectorViewModelFactory.CreateExport().Value;

            countrySelectorViewModel.Province  = province;
            countrySelectorViewModel.Countries = _entityService.Countries;

            if (countrySelectorViewModel.ShowDialog(_viewService.ShellView))
            {
                province.Country = countrySelectorViewModel.SelectedCountry;
            }
        }
Example #12
0
        /// <summary>
        /// Get the province with the specified identifier.
        /// </summary>
        /// <returns>The province.</returns>
        /// <param name="id">Identifier.</param>
        public ProvinceEntity Get(string id)
        {
            List <ProvinceEntity> provinceEntities = xmlDatabase.LoadEntities().ToList();
            ProvinceEntity        provinceEntity   = provinceEntities.FirstOrDefault(x => x.Id == id);

            if (provinceEntity == null)
            {
                throw new EntityNotFoundException(id, nameof(BorderEntity).Replace("Entity", ""));
            }

            return(provinceEntity);
        }
Example #13
0
 public ActionResult SubmitForm(ProvinceEntity entity, Guid?keyValue)
 {
     if (keyValue != null)
     {
         entity.ProvinceId = (Guid)keyValue;
         provinceApp.Update(entity);
     }
     else
     {
         entity.ProvinceId = Guid.NewGuid();
         provinceApp.Insert(entity);
     }
     return(Success("操作成功。"));
 }
Example #14
0
        /// <summary>
        /// Adds the specified province.
        /// </summary>
        /// <param name="provinceEntity">Province.</param>
        public void Add(ProvinceEntity provinceEntity)
        {
            List <ProvinceEntity> provinceEntities = xmlDatabase.LoadEntities().ToList();

            provinceEntities.Add(provinceEntity);

            try
            {
                xmlDatabase.SaveEntities(provinceEntities);
            }
            catch
            {
                throw new DuplicateEntityException(provinceEntity.Id, nameof(ProvinceEntity).Replace("Entity", ""));
            }
        }
Example #15
0
        /// <summary>
        /// 编辑
        /// </summary>
        private void ShowEditProvince()
        {
            ProvinceEntity editEntity = SelectedProvinceRow;

            if (editEntity == null)
            {
                MsgBox.Warn("没有要修改的数据。");
                return;
            }

            FrmProvinceEdit frmProvinceEdit = new FrmProvinceEdit(editEntity);

            frmProvinceEdit.DataSourceChanged += OnEditChanage;
            frmProvinceEdit.ShowDialog();
        }
        /// <summary>
        /// Converts the domain model into an entity.
        /// </summary>
        /// <returns>The entity.</returns>
        /// <param name="province">Province.</param>
        internal static ProvinceEntity ToEntity(this Province province)
        {
            ProvinceEntity provinceEntity = new ProvinceEntity
            {
                Id                 = province.Id,
                Name               = province.Name,
                Description        = province.Description,
                ColourHexadecimal  = ColorTranslator.ToHtml(province.Colour),
                Type               = province.Type.ToString(),
                ResourceId         = province.ResourceId,
                FactionId          = province.FactionId,
                SovereignFactionId = province.SovereignFactionId
            };

            return(provinceEntity);
        }
        /// <summary>
        /// Converts the entity into a domain model.
        /// </summary>
        /// <returns>The domain model.</returns>
        /// <param name="provinceEntity">Province entity.</param>
        internal static Province ToDomainModel(this ProvinceEntity provinceEntity)
        {
            Province province = new Province
            {
                Id                 = provinceEntity.Id,
                Name               = provinceEntity.Name,
                Description        = provinceEntity.Description,
                Colour             = ColorTranslator.FromHtml(provinceEntity.ColourHexadecimal),
                Type               = (ProvinceType)Enum.Parse(typeof(ProvinceType), provinceEntity.Type),
                ResourceId         = provinceEntity.ResourceId,
                FactionId          = provinceEntity.FactionId,
                SovereignFactionId = provinceEntity.SovereignFactionId
            };

            return(province);
        }
Example #18
0
        public async Task SeedAsync(DataSeedContext context)
        {
            var provinceE = new ProvinceEntity("Western");
            var districtE = new DistrictEntity("Colombo", provinceE.Id);
            var cityE     = new CityEntity(districtE.Id)
            {
                CityName    = "Delkanda",
                Geolocation = "6.784568:79.546545"
            };

            await ProvinceRepo.InsertAsync(provinceE);

            await DistrictRepo.InsertAsync(districtE);

            await CityRepo.InsertAsync(cityE);
        }
Example #19
0
        public ProvinceEntity PrepareSave()
        {
            ProvinceEntity editEntity = ProvinceEntity;

            if (editEntity == null)
            {
                editEntity = new ProvinceEntity();
            }
            editEntity.ProvinceCode = txtCode.Text.Trim();
            editEntity.ProvinceName = txtName.Text.Trim();
            editEntity.AliasName    = txtAliasName.Text.Trim();
            editEntity.AreaCode     = txtAreaCode.Text.Trim();
            editEntity.Capital      = txtCapital.Text.Trim();
            editEntity.NamePY       = txtNamePY.Text.Trim();

            return(editEntity);
        }
        public ProvinceDTO save(ProvinceEntity entity)
        {
            var transaction = _humanManagerContext.Database.BeginTransaction();

            try
            {
                entity = _humanManagerContext.Provinces.Add(entity).Entity;
                _humanManagerContext.SaveChanges();

                transaction.Commit();
                ProvinceDTO dto = _mapper.Map <ProvinceDTO>(entity);
                return(dto);
            }
            catch
            {
                transaction.Rollback();
                return(null);
            }
        }
Example #21
0
        /// <summary>
        /// Updates the specified province.
        /// </summary>
        /// <param name="provinceEntity">Province.</param>
        public void Update(ProvinceEntity provinceEntity)
        {
            List <ProvinceEntity> provinceEntities       = xmlDatabase.LoadEntities().ToList();
            ProvinceEntity        provinceEntityToUpdate = provinceEntities.FirstOrDefault(x => x.Id == provinceEntity.Id);

            if (provinceEntityToUpdate == null)
            {
                throw new EntityNotFoundException(provinceEntity.Id, nameof(BorderEntity).Replace("Entity", ""));
            }

            provinceEntityToUpdate.Name               = provinceEntity.Name;
            provinceEntityToUpdate.Description        = provinceEntity.Description;
            provinceEntityToUpdate.ColourHexadecimal  = provinceEntity.ColourHexadecimal;
            provinceEntityToUpdate.Type               = provinceEntity.Type;
            provinceEntityToUpdate.FactionId          = provinceEntity.FactionId;
            provinceEntityToUpdate.SovereignFactionId = provinceEntity.SovereignFactionId;

            xmlDatabase.SaveEntities(provinceEntities);
        }
Example #22
0
        /// <summary>
        /// 添加或编辑省份
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="operatorFlag">添加或编辑</param>
        /// <returns></returns>
        public int Save(ProvinceEntity entity, bool isNew)
        {
            IMapper map = DatabaseInstance.Instance();
            int     ret = -2;

            if (isNew)
            {
                //检查编号是否已经存在
                if (IsProvinceCodeExists(entity))
                {
                    return(-1);
                }
                ret = map.Execute("insert into PROVINCES(PROV_CODE, PROV_NAME, ALIASNAME, AREACODE, CAPITAL, NAME_PY) " +
                                  "values(@Code, @Name, @AliasName, @AreaCode, @Capital, @NamePY)",
                                  new
                {
                    Code      = entity.ProvinceCode,
                    Name      = entity.ProvinceName,
                    AliasName = entity.AliasName,
                    AreaCode  = entity.AreaCode,
                    Capital   = entity.Capital,
                    NamePY    = entity.NamePY,
                });
            }
            else
            {
                //更新
                ret = map.Execute("update PROVINCES set PROV_NAME = @Name, ALIASNAME = @AliasName, AREACODE = @AreaCode, CAPITAL = @Capital, NAME_PY = @NamePY where PROV_CODE = @COD",
                                  new
                {
                    Name      = entity.ProvinceName,
                    AliasName = entity.AliasName,
                    AreaCode  = entity.AreaCode,
                    Capital   = entity.Capital,
                    NamePY    = entity.NamePY,
                    COD       = entity.ProvinceCode
                });
            }
            return(ret);
        }
Example #23
0
        /// <summary>
        /// 删除
        /// </summary>
        private void DoDeleteSelectedProvince()
        {
            ProvinceEntity removeEntity = SelectedProvinceRow;

            if (removeEntity == null)
            {
                MsgBox.Warn("没有要删除的数据。");
                return;
            }

            if (MsgBox.AskOK(string.Format("确定要删除省份{0}吗?", removeEntity.ProvinceName)) == DialogResult.OK)
            {
                int result = ProvinceDal.DeleteProvince(removeEntity.ProvinceCode);
                if (result == 1)
                {
                    bindingSource1.Remove(removeEntity);
                }
                else
                {
                    MsgBox.Warn("删除失败,可能已经被其他人删除。");
                }
            }
        }
Example #24
0
        /// <summary>
        /// 查询站点列表和省份集合
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public StructuralEntity GetSationList(string CompanyID, string UserID)
        {
            StructuralEntity StEntity = new StructuralEntity();
            //加载操作表格对象
            AbsFacory      absfact = AbsFacory.CreatInstance();
            IhydStationBLL hsbll   = absfact.CreathydStationBllInstance();
            IWM_CompanyBLL cbll    = absfact.CreatIWM_CompanyBLLInstance();

            //超级管理员账户
            if (UserID == ConfigHelper.AppSettings("CurrentUserName"))
            {
                //加载所有站点信息
                //List<hydStation> hs = hsbll.Query(p=>true).ToList();
                //加载所有省份信息
                List <ProvinceEntity> pentity = new List <ProvinceEntity>();
                var pe = cbll.Query(p => true)
                         .Select(x => new
                {
                    x.Province
                }).Distinct().ToList();
                for (int i = 0; i < pe.Count; i++)
                {
                    ProvinceEntity ppe = new ProvinceEntity();
                    ppe.Province = pe[i].Province;
                    pentity.Add(ppe);
                }
                //StEntity.stationEntity = hs;
                StEntity.provinceEntity = pentity;
            }
            else//区域管理员账户
            {
                //加载区域管理员账户管辖的所有站点信息
                //List<hydStation> hs = new List<hydStation>();
                //List<ProvinceEntity> pe = new List<ProvinceEntity>();
                var pe = cbll.Query(p => p.CompanyId == CompanyID)
                         .Select(x => new ProvinceEntity
                {
                    Province = x.Province,
                    City     = x.City,
                    County   = x.County
                }).FirstOrDefault();
                //if ((pe.City==""||pe.City==null||pe.City== "&nbsp;")&&(pe.County==""||pe.City==null||pe.County== "&nbsp;"))
                //{
                //    hs = hsbll.Query(p => p.Province == pe.Province).ToList();
                //}
                //else if((pe.City != "" || pe.City != null || pe.City != "&nbsp;") && (pe.County == "" || pe.City == null || pe.County == "&nbsp;"))
                //{
                //    hs = hsbll.Query(p => p.Province == pe.Province&&p.City==pe.City).ToList();
                //}
                //else if ((pe.City != "" || pe.City != null || pe.City != "&nbsp;") && (pe.County != "" || pe.City != null || pe.County != "&nbsp;"))
                //{
                //    hs = hsbll.Query(p => p.Province == pe.Province && p.City == pe.City&&p.County==pe.County).ToList();
                //}
                List <ProvinceEntity> provice = new List <ProvinceEntity>();
                ProvinceEntity        pentity = new ProvinceEntity();
                pentity.Province = pe.Province;
                provice.Add(pentity);
                //StEntity.stationEntity = hs;
                StEntity.provinceEntity = provice;
            }
            return(StEntity);
        }
Example #25
0
 public FrmProvinceEdit(ProvinceEntity ProvinceEntity)
     : this()
 {
     this.ProvinceEntity = ProvinceEntity;
 }