Пример #1
0
        private MideFrameWork.Data.Entity.DistrictEntity GetDistrict(DataRow dr)
        {
            MideFrameWork.Data.Entity.DistrictEntity info = new MideFrameWork.Data.Entity.DistrictEntity();
										if(DBNull.Value==dr["ID"])
					info.ID=0;
				else
					info.ID=int.Parse(dr["ID"].ToString());
									
																						if(DBNull.Value==dr["ParentID"])
					info.ParentID=0;
				else
					info.ParentID=int.Parse(dr["ParentID"].ToString());
									
																								
						if(DBNull.Value==dr["DistrictName"])
				info.DistrictName= string.Empty;
			else	
				info.DistrictName= dr["DistrictName"].ToString();
																						if(DBNull.Value==dr["Status"])
					info.Status=0;
				else
					info.Status=int.Parse(dr["Status"].ToString());
									
															            return info;
        }
        protected void DistrictEditFunc(string ctrID)
        {

            int ParentId = Convert.ToInt32(Request.Form["DropDownList_ParentID"]);
            int status = Convert.ToInt32(Request.Form["DropDownList_Status"]);
            string DistrictName = Request.Form["TextBox_DistrictName"].Trim();
            if (string.IsNullOrEmpty(DistrictName))
            {
                Alert("地区名称不能为空");
                return;
            }
            //检查在该父菜单下是否存在相同的地区名称
            IList<DistrictEntity> DistrictExist = DataProvider.GetInstance().GetDistrictList(" DistrictName='" + DistrictName + "' and ParentID=" + ParentId + " and ID<>" + ctrID);

            if (DistrictExist.ToList().Count > 0)
            {
                Alert("在该父菜单下存在相同的地区名称");
                return;
            }

            DistrictEntity District = new DistrictEntity();
            District.ID = Convert.ToInt32(ctrID);
            District.ParentID = ParentId;
            District.Status = status;
            District.DistrictName = DistrictName;
            try
            {
                DataProvider.GetInstance().UpdateDistrict(District);
            }
            catch
            {
                WriteLog("DistrictEditFunc", "编辑地区", "把地区名称更新到数据库时出错", Common.DailyUtility.MideSmsType.LogType.SystemLog);
                Alert("更新数据时出错,请重试");
            }
            Alert("编辑成功", "?ctrID=" + ctrID);
        }