コード例 #1
0
        private void UpdateMapUnit(List<v_Unit> _lstUnit, string DiemTiepNhanId)
        {
            string cProvinceCode = "";
            string cDistrictCode = "";
            TinhThanh objTinhThanh = new TinhThanh();
            QuanHuyen objQuanHuyen = new QuanHuyen();
            //objNew = item;
            string tenDiemTiepNhan = lstDTN.FirstOrDefault(t => t.Id.Equals(DiemTiepNhanId)).Name;

            //_lstUnit.ForEach(a => { a.DiemTiepNhanId = DiemTiepNhanId; a.DiemTiepNhanName = objDTN.Name; });
            foreach (v_Unit item in _lstUnit)
            {
                if (!item.ProvinceCode.Equals(cProvinceCode))
                {
                    cProvinceCode = item.ProvinceCode;
                    objTinhThanh = this.lstTinhThanh.Find(a => a.ProvinceCode.Equals(cProvinceCode));
                }
                if (!item.DistrictCode.Equals(cDistrictCode))
                {
                    cDistrictCode = item.DistrictCode;
                    objQuanHuyen = objTinhThanh.lstQuanHuyen.Find(a => a.DistrictCode.Equals(cDistrictCode));
                }
                v_Unit setUnit = objTinhThanh.lstUnitMap.Find(a => a.UnitCode == item.UnitCode);
                if (setUnit != null) {
                    item.DiemTiepNhanId = DiemTiepNhanId;
                    item.DiemTiepNhanName = tenDiemTiepNhan;
                    setUnit.DiemTiepNhanId = DiemTiepNhanId;
                    setUnit.DiemTiepNhanName = tenDiemTiepNhan;
                    setUnit = objQuanHuyen.lstUnitMap.Find(a => a.UnitCode == item.UnitCode);
                    setUnit.DiemTiepNhanId = DiemTiepNhanId;
                    setUnit.DiemTiepNhanName = tenDiemTiepNhan;
                    //_lstUnit.Remove(item);
                }
                else
                {
                    item.DiemTiepNhanId = DiemTiepNhanId;
                    item.DiemTiepNhanName = tenDiemTiepNhan;
                    objTinhThanh.lstUnitMap.Add(item);
                    objQuanHuyen.lstUnitMap.Add(item);
                    objTinhThanh.lstUnitNotMap.RemoveAt(objTinhThanh.lstUnitNotMap.FindIndex(a => a.UnitCode == item.UnitCode));
                    objQuanHuyen.lstUnitNotMap.RemoveAt(objQuanHuyen.lstUnitNotMap.FindIndex(a => a.UnitCode == item.UnitCode));
                }
                //objTinhThanh.lstUnitMap.Remove(item);
                //objQuanHuyen.lstUnitMap.Add(item);
            }
            if (_lstUnit.Count > 0)
            {
                //AddMapUnit(_lstUnit, DiemTiepNhanId);
            }
        }
コード例 #2
0
        private void UpdateMapDistrict(List<QuanHuyen> _lstQuanHuyen, string DiemTiepNhanId)
        {
            string cProvinceCode = "";
            string cDistrictCode = "";
            TinhThanh objTinhThanh = new TinhThanh();
            QuanHuyen objQuanHuyen = new QuanHuyen();
            //objNew = item;
            string tenDiemTiepNhan = lstDTN.FirstOrDefault(t => t.Id.Equals(DiemTiepNhanId)).Name;

            //_lstUnit.ForEach(a => { a.DiemTiepNhanId = DiemTiepNhanId; a.DiemTiepNhanName = objDTN.Name; });
            foreach (QuanHuyen item in _lstQuanHuyen)
            {
                if (!item.ProvinceCode.Equals(cProvinceCode))
                {
                    cProvinceCode = item.ProvinceCode;
                    objTinhThanh = this.lstTinhThanh.Find(a => a.ProvinceCode.Equals(cProvinceCode));
                }
                foreach (v_Unit unit in item.lstUnit)
                {
                    unit.DiemTiepNhanId = item.DiemTiepNhanId;
                    unit.DiemTiepNhanName = item.DiemTiepNhanName;
                }
                cDistrictCode = item.DistrictCode;
                objQuanHuyen = objTinhThanh.lstQuanHuyen.Find(a => a.DistrictCode.Equals(item.DistrictCode));
                objQuanHuyen.DiemTiepNhanName = tenDiemTiepNhan;
                objQuanHuyen.DiemTiepNhanId = DiemTiepNhanId;

            }
        }
コード例 #3
0
        private void AddMapUnit(List<v_Unit> _lstUnit, string DiemTiepNhanId = null)
        {
            string cProvinceCode = "";
            string cDistrictCode = "";
            TinhThanh objTinhThanh = new TinhThanh();
            QuanHuyen objQuanHuyen = new QuanHuyen();

            BDiemTiepNhan objDTN = new BDiemTiepNhan();
            objDTN = lstDTN.FirstOrDefault(t => t.Id.Equals(DiemTiepNhanId));

            foreach (v_Unit item in _lstUnit)
            {
                if (!String.IsNullOrWhiteSpace(DiemTiepNhanId))
                {
                    item.DiemTiepNhanId = DiemTiepNhanId;
                    item.DiemTiepNhanName = objDTN.Name;
                }

                if (!item.ProvinceCode.Equals(cProvinceCode))
                {
                    cProvinceCode = item.ProvinceCode;
                    objTinhThanh = this.lstTinhThanh.Find(a => a.ProvinceCode.Equals(cProvinceCode));
                }
                if (!item.DistrictCode.Equals(cDistrictCode))
                {
                    cDistrictCode = item.DistrictCode;
                    objQuanHuyen = objTinhThanh.lstQuanHuyen.Find(a => a.DistrictCode.Equals(cDistrictCode));
                }
                v_Unit objLstUnit = objQuanHuyen.lstUnit.Find(a => a.UnitCode == item.UnitCode);
                objLstUnit.DiemTiepNhanId = item.DiemTiepNhanId;
                objLstUnit.DiemTiepNhanName = item.DiemTiepNhanName;

                objTinhThanh.lstUnitMap.Add(item);
                int index = objTinhThanh.lstUnitNotMap.FindIndex(a => a.UnitCode == item.UnitCode);
                if (index > 0) {
                    objTinhThanh.lstUnitNotMap.RemoveAt(index);
                }
                else
                {
                    int indexMap = objTinhThanh.lstUnitMap.FindIndex(a => a.UnitCode == item.UnitCode);
                    objTinhThanh.lstUnitMap[indexMap].DiemTiepNhanId = item.DiemTiepNhanId;
                    objTinhThanh.lstUnitMap[indexMap].DiemTiepNhanName = item.DiemTiepNhanName;
                }

                objQuanHuyen.lstUnitMap.Add(item);
                index = objQuanHuyen.lstUnitNotMap.FindIndex(a => a.UnitCode == item.UnitCode);
                if (index > 0)
                {
                    objQuanHuyen.lstUnitNotMap.RemoveAt(index);
                }
                else
                {
                    int indexMap = objQuanHuyen.lstUnitMap.FindIndex(a => a.UnitCode == item.UnitCode);
                    objQuanHuyen.lstUnitMap[indexMap].DiemTiepNhanId = item.DiemTiepNhanId;
                    objQuanHuyen.lstUnitMap[indexMap].DiemTiepNhanName = item.DiemTiepNhanName;
                }

            }
        }
コード例 #4
0
        private void build()
        {
            lstTinhThanh = new List<TinhThanh>();
            lstQuanHuyen = new List<QuanHuyen>();
            string cProvinceCode = "";
            string cDistrictCode = "";
            TinhThanh objTinhThanh = new TinhThanh();
            QuanHuyen objQuanHuyen = new QuanHuyen();
            foreach (v_Unit item in this.lstUnit)
            {
                if (!item.ProvinceCode.Equals(cProvinceCode))
                {
                    cProvinceCode = item.ProvinceCode;
                    objTinhThanh = new TinhThanh();
                    objTinhThanh.ProvinceCode = item.ProvinceCode;
                    objTinhThanh.ProvinceName = lstProvince.Find(p => p.ProvinceCode.Equals(objTinhThanh.ProvinceCode)).ProvinceName;
                    lstTinhThanh.Add(objTinhThanh);
                }
                if (!item.DistrictCode.Equals(cDistrictCode))
                {
                    cDistrictCode = item.DistrictCode;
                    objQuanHuyen = new QuanHuyen();
                    objQuanHuyen.DistrictCode = item.DistrictCode;
                    objQuanHuyen.DistrictName = item.DistrictName;
                    objQuanHuyen.ProvinceCode = item.ProvinceCode;
                    objQuanHuyen.ProvinceName = objTinhThanh.ProvinceName;
                    lstQuanHuyen.Add(objQuanHuyen);
                    objTinhThanh.lstQuanHuyen.Add(objQuanHuyen);
                }
                objTinhThanh.lstUnit.Add(item);
                objTinhThanh.lstUnitNotMap.Add(item);

                objQuanHuyen.lstUnit.Add(item);
                objQuanHuyen.lstUnitNotMap.Add(item);
            }
        }
コード例 #5
0
        private void AddMapDistrict(List<QuanHuyen> _lstDistrict, string DiemTiepNhanId = null)
        {
            string cProvinceCode = "";
            TinhThanh objTinhThanh = new TinhThanh();
            QuanHuyen objQuanHuyen = new QuanHuyen();

            BDiemTiepNhan objDTN = new BDiemTiepNhan();
            objDTN = lstDTN.FirstOrDefault(t => t.Id.Equals(DiemTiepNhanId));

            foreach (QuanHuyen item in _lstDistrict)
            {
                if (!String.IsNullOrWhiteSpace(DiemTiepNhanId))
                {
                    item.DiemTiepNhanId = DiemTiepNhanId;
                    item.DiemTiepNhanName = objDTN.Name;
                }
                if (!item.ProvinceCode.Equals(cProvinceCode))
                {
                    cProvinceCode = item.ProvinceCode;
                    objTinhThanh = this.lstTinhThanh.Find(a => a.ProvinceCode.Equals(cProvinceCode));
                }
                foreach (v_Unit unit in item.lstUnit)
                {
                    unit.DiemTiepNhanId = item.DiemTiepNhanId;
                    unit.DiemTiepNhanName = item.DiemTiepNhanName;
                }
                objQuanHuyen = objTinhThanh.lstQuanHuyen.Find(a => a.DistrictCode.Equals(item.DistrictCode));
                objQuanHuyen.DiemTiepNhanId = item.DiemTiepNhanId;
                objQuanHuyen.DiemTiepNhanName = item.DiemTiepNhanName;

            }
        }