public int CompareTo(object obj) { AreaInfo b = obj as AreaInfo; //if ( String.Compare(this.OrderNumber, b.OrderNumber) >= 0 ) // return 1; //else // return -1; if (string.Compare(this.DistrictName, b.DistrictName) >= 0) { return(1); } else { return(-1); } }
public int UpdateArea(AreaInfo oParam) { string sql = @"UPDATE Area SET ProvinceSysNo=@ProvinceSysNo, CitySysNo=@CitySysNo, ProvinceName=@ProvinceName, CityName=@CityName, DistrictName=@DistrictName, IsLocal=@IsLocal, Status=@Status,LocalCode=@LocalCode WHERE SysNo=@SysNo"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4); SqlParameter paramProvinceSysNo = new SqlParameter("@ProvinceSysNo", SqlDbType.Int, 4); SqlParameter paramCitySysNo = new SqlParameter("@CitySysNo", SqlDbType.Int, 4); SqlParameter paramProvinceName = new SqlParameter("@ProvinceName", SqlDbType.NVarChar, 20); SqlParameter paramCityName = new SqlParameter("@CityName", SqlDbType.NVarChar, 20); SqlParameter paramDistrictName = new SqlParameter("@DistrictName", SqlDbType.NVarChar, 200); SqlParameter paramIsLocal = new SqlParameter("@IsLocal", SqlDbType.Int, 4); SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int, 4); SqlParameter paramLocalCode = new SqlParameter("@LocalCode", SqlDbType.Int, 4); paramSysNo.Value = oParam.SysNo; paramProvinceSysNo.Value = oParam.ProvinceSysNo; paramCitySysNo.Value = oParam.CitySysNo; paramProvinceName.Value = oParam.ProvinceName; paramCityName.Value = oParam.CityName; paramDistrictName.Value = oParam.DistrictName; paramIsLocal.Value = oParam.IsLocal; paramStatus.Value = oParam.Status; paramLocalCode.Value = oParam.LocalCode; cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramProvinceSysNo); cmd.Parameters.Add(paramCitySysNo); cmd.Parameters.Add(paramProvinceName); cmd.Parameters.Add(paramCityName); cmd.Parameters.Add(paramDistrictName); cmd.Parameters.Add(paramIsLocal); cmd.Parameters.Add(paramStatus); cmd.Parameters.Add(paramLocalCode); return SqlHelper.ExecuteNonQuery(cmd); }
public int InsertArea(AreaInfo oParam) { string sql = @"INSERT INTO Area ( SysNo, ProvinceSysNo, CitySysNo, ProvinceName, CityName, DistrictName, IsLocal, Status,LocalCode ) VALUES ( @SysNo, @ProvinceSysNo, @CitySysNo, @ProvinceName, @CityName, @DistrictName, @IsLocal, @Status,@LocalCode ); set @sysno = SCOPE_IDENTITY(); "; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4); SqlParameter paramProvinceSysNo = new SqlParameter("@ProvinceSysNo", SqlDbType.Int, 4); SqlParameter paramCitySysNo = new SqlParameter("@CitySysNo", SqlDbType.Int, 4); SqlParameter paramProvinceName = new SqlParameter("@ProvinceName", SqlDbType.NVarChar, 20); SqlParameter paramCityName = new SqlParameter("@CityName", SqlDbType.NVarChar, 20); SqlParameter paramDistrictName = new SqlParameter("@DistrictName", SqlDbType.NVarChar, 200); SqlParameter paramIsLocal = new SqlParameter("@IsLocal", SqlDbType.Int, 4); SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int, 4); SqlParameter paramLocalCode = new SqlParameter("@LocalCode", SqlDbType.Int, 4); paramSysNo.Value = oParam.SysNo; if (oParam.ProvinceSysNo != AppConst.IntNull) paramProvinceSysNo.Value = oParam.ProvinceSysNo; else paramProvinceSysNo.Value = System.DBNull.Value; if (oParam.CitySysNo != AppConst.IntNull) paramCitySysNo.Value = oParam.CitySysNo; else paramCitySysNo.Value = System.DBNull.Value; paramProvinceName.Value = oParam.ProvinceName; if (oParam.CityName != AppConst.StringNull) paramCityName.Value = oParam.CityName; else paramCityName.Value = System.DBNull.Value; if (oParam.DistrictName != AppConst.StringNull) paramDistrictName.Value = oParam.DistrictName; else paramDistrictName.Value = System.DBNull.Value; if (oParam.LocalCode != AppConst.IntNull) paramLocalCode.Value = oParam.LocalCode; else paramLocalCode.Value = System.DBNull.Value; paramIsLocal.Value = oParam.IsLocal; paramStatus.Value = oParam.Status; cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramProvinceSysNo); cmd.Parameters.Add(paramCitySysNo); cmd.Parameters.Add(paramProvinceName); cmd.Parameters.Add(paramCityName); cmd.Parameters.Add(paramDistrictName); cmd.Parameters.Add(paramIsLocal); cmd.Parameters.Add(paramStatus); cmd.Parameters.Add(paramLocalCode); return SqlHelper.ExecuteNonQuery(cmd); }
public int GetAreaType(AreaInfo oParam) { if (oParam.CitySysNo != AppConst.IntNull) return (int)AppEnum.AreaType.District; else if (oParam.ProvinceSysNo != AppConst.IntNull) return (int)AppEnum.AreaType.City; else return (int)AppEnum.AreaType.Province; }
public void ImportArea() { if (!AppConfig.IsImportable) throw new BizException("Is Importable is false"); /* do not use the following code after Data Pour in */ string sql = " select top 1 * from area "; DataSet ds = SqlHelper.ExecuteDataSet(sql); if (Util.HasMoreRow(ds)) throw new BizException("the table area is not empty"); TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { string sql1 = "select * from ipp2003..area where countrySysNo = 1 and provinceSysNo = 0"; //ͨ��ʡ�� and SysNo <> 36"; DataSet ds1 = SqlHelper.ExecuteDataSet(sql1); foreach (DataRow dr1 in ds1.Tables[0].Rows) { AreaInfo oProvince = new AreaInfo(); oProvince.ProvinceName = Util.TrimNull(dr1["ProvinceName"]); oProvince.IsLocal = Util.TrimIntNull(dr1["IsLocal"]); oProvince.Status = Util.TrimIntNull(dr1["Status"]); oProvince.OrderNumber = "zzz"; this.InsertArea(oProvince); //insert into convert table ImportInfo oProvinceConvert = new ImportInfo(); oProvinceConvert.OldSysNo = Util.TrimIntNull(dr1["SysNo"]); oProvinceConvert.NewSysNo = oProvince.SysNo; new ImportDac().Insert(oProvinceConvert, "Area"); string sql2 = "select * from ipp2003..area where provinceSysNo = " + Util.TrimIntNull(dr1["SysNo"]) + " and citySysNo = 0 "; DataSet ds2 = SqlHelper.ExecuteDataSet(sql2); foreach (DataRow dr2 in ds2.Tables[0].Rows) { AreaInfo oCity = new AreaInfo(); oCity.ProvinceSysNo = oProvince.SysNo; oCity.ProvinceName = Util.TrimNull(dr1["ProvinceName"]); oCity.CityName = Util.TrimNull(dr2["CityName"]); oCity.IsLocal = Util.TrimIntNull(dr2["IsLocal"]); oCity.Status = Util.TrimIntNull(dr2["Status"]); oCity.OrderNumber = "zzz"; this.InsertArea(oCity); //insert into convert table ImportInfo oCityConvert = new ImportInfo(); oCityConvert.OldSysNo = Util.TrimIntNull(dr2["SysNo"]); oCityConvert.NewSysNo = oCity.SysNo; new ImportDac().Insert(oCityConvert, "Area"); string sql3 = "select * from ipp2003..area where citySysNo = " + Util.TrimIntNull(dr2["SysNo"]); DataSet ds3 = SqlHelper.ExecuteDataSet(sql3); foreach (DataRow dr3 in ds3.Tables[0].Rows) { AreaInfo oDistrict = new AreaInfo(); oDistrict.ProvinceSysNo = oCity.ProvinceSysNo; oDistrict.CitySysNo = oCity.SysNo; oDistrict.ProvinceName = Util.TrimNull(dr3["ProvinceName"]); oDistrict.CityName = Util.TrimNull(dr3["CityName"]); oDistrict.DistrictName = Util.TrimNull(dr3["DistrictName"]); oDistrict.IsLocal = Util.TrimIntNull(dr3["IsLocal"]); oDistrict.Status = Util.TrimIntNull(dr3["Status"]); oDistrict.OrderNumber = "zzz"; this.InsertArea(oDistrict); //insert into convert table ImportInfo oDistrictConvert = new ImportInfo(); oDistrictConvert.OldSysNo = Util.TrimIntNull(dr3["SysNo"]); oDistrictConvert.NewSysNo = oDistrict.SysNo; new ImportDac().Insert(oDistrictConvert, "Area"); } } } scope.Complete(); } }
/// <summary> /// ������Ȼ�ñ�������Ӧ��ȵĵ����� /// </summary> /// <param name="depth"></param> /// <returns></returns> public int GetAreaSysNo(int depth, AreaInfo oArea) { if (depth == this.GetAreaType(oArea)) { return oArea.SysNo; } switch (depth) { case (int)AppEnum.AreaType.Province: return oArea.ProvinceSysNo; case (int)AppEnum.AreaType.City: return oArea.CitySysNo; case (int)AppEnum.AreaType.District: return oArea.SysNo; default: return 0; } }
private void Map(AreaInfo oParam, DataRow tempdr) { oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]); oParam.ProvinceSysNo = Util.TrimIntNull(tempdr["ProvinceSysNo"]); oParam.CitySysNo = Util.TrimIntNull(tempdr["CitySysNo"]); oParam.ProvinceName = Util.TrimNull(tempdr["ProvinceName"]); oParam.CityName = Util.TrimNull(tempdr["CityName"]); oParam.DistrictName = Util.TrimNull(tempdr["DistrictName"]); oParam.OrderNumber = Util.TrimNull(tempdr["OrderNumber"]); oParam.IsLocal = Util.TrimIntNull(tempdr["IsLocal"]); oParam.Status = Util.TrimIntNull(tempdr["Status"]); oParam.LocalCode = Util.TrimIntNull(tempdr["LocalCode"]); }
public int UpdateArea(AreaInfo oParam) { if (!areaHash.ContainsKey(oParam.SysNo)) throw new BizException("the area does not exist, update failed"); int result = new ASPDac().UpdateArea(oParam); SyncManager.GetInstance().SetDbLastVersion((int)AppEnum.Sync.ASP); areaHash.Remove(oParam.SysNo); areaHash.Add(oParam.SysNo, oParam); return result; }
public int InsertArea(AreaInfo oParam) { if (!AppConfig.IsImportable) foreach (AreaInfo item in areaHash.Values) { if (item.GetWholeName() == oParam.GetWholeName()) throw new BizException("area duplicated"); } oParam.SysNo = SequenceDac.GetInstance().Create("Area_Sequence"); int result = new ASPDac().InsertArea(oParam); SyncManager.GetInstance().SetDbLastVersion((int)AppEnum.Sync.ASP); areaHash.Add(oParam.SysNo, oParam); return result; }
public void InitArea() { lock (areaLock) { if (areaHash != null) areaHash.Clear(); string sql = "select * from area order by ProvinceName,CityName,DistrictName"; DataSet ds = SqlHelper.ExecuteDataSet(sql); if (!Util.HasMoreRow(ds)) return; foreach (DataRow dr in ds.Tables[0].Rows) { AreaInfo item = new AreaInfo(); Map(item, dr); if (areaHash == null) { areaHash = new Hashtable(1000); } areaHash.Add(item.SysNo, item); } } }