protected void init_form(string ctrID)
        {
            if (!string.IsNullOrEmpty(ctrID))
            {
                _Base_PrivilegeEntity = DataProvider.GetInstance().GetBase_PrivilegeEntity(int.Parse(ctrID));

               				                				                   TextBox_UserID.Text = _Base_PrivilegeEntity.UserID.ToString();
                                				                   TextBox_ModuleID.Text = _Base_PrivilegeEntity.ModuleID.ToString();
                                				                   TextBox_ButtonID.Text = _Base_PrivilegeEntity.ButtonID.ToString();
                                				                   TextBox_CreaterID.Text = _Base_PrivilegeEntity.CreaterID.ToString();
                                				                   TextBox_UpdaterID.Text = _Base_PrivilegeEntity.UpdaterID.ToString();
                                				                				                            }
        }
        protected void Base_PrivilegeAdd()
        {
            #region 判断是否可空
		 
                                                                          
                  var _UserID = Request.Form["TextBox_UserID"];
                 if (string.IsNullOrEmpty(_UserID))
                   {
                        Alert("[ 用户ID ]不能为空");
                        return;
                  }
				                                           
                  var _ModuleID = Request.Form["TextBox_ModuleID"];
                 if (string.IsNullOrEmpty(_ModuleID))
                   {
                        Alert("[ 模块ID ]不能为空");
                        return;
                  }
				                                           
                  var _ButtonID = Request.Form["TextBox_ButtonID"];
                 if (string.IsNullOrEmpty(_ButtonID))
                   {
                        Alert("[ 操作ID ]不能为空");
                        return;
                  }
				                                           
                  var _CreaterID = Request.Form["TextBox_CreaterID"];
                 if (string.IsNullOrEmpty(_CreaterID))
                   {
                        Alert("[ 创建者ID ]不能为空");
                        return;
                  }
				                                           
                  var _UpdaterID = Request.Form["TextBox_UpdaterID"];
                 if (string.IsNullOrEmpty(_UpdaterID))
                   {
                        Alert("[ 更新者ID ]不能为空");
                        return;
                  }
				                                                                                
	        #endregion
           
            #region 获取数据

            Base_PrivilegeEntity  _Base_PrivilegeEntity = new Base_PrivilegeEntity();
            
               		                               	  		                            
                 	                 	                     _Base_PrivilegeEntity.UserID =Convert.ToInt32(_UserID.ToString());
                	                        	  		                            
                 	                 	                     _Base_PrivilegeEntity.ModuleID =Convert.ToInt32(_ModuleID.ToString());
                	                        	  		                            
                 	                 	                     _Base_PrivilegeEntity.ButtonID =Convert.ToInt32(_ButtonID.ToString());
                	                        	  		                            
                 	                 	                     _Base_PrivilegeEntity.CreaterID =Convert.ToInt32(_CreaterID.ToString());
                	                        	  		                            
                 	                 	                     _Base_PrivilegeEntity.UpdaterID =Convert.ToInt32(_UpdaterID.ToString());
                	                        	  		        
		       	_Base_PrivilegeEntity.CreateDate =DateTime.Now;
		               	  		        
		       	_Base_PrivilegeEntity.UpdateDate =DateTime.Now;
		               	              try
            {
                DataProvider.GetInstance().AddBase_Privilege(_Base_PrivilegeEntity);
            }
            catch
            {
                WriteLog("Base_PrivilegeAdd", "添加Base_Privilege", "插入数据库时出错", Common.DailyUtility.MideSmsType.LogType.SystemLog);
                Alert("添加数据时出错,请重试");
                return;
            }
            Alert("添加Base_Privilege成功");
        }
        void Button_submit_Click(object sender, EventArgs e)
        {
            int[] idsArray = GetSelected(Base_ButtonList);


            string whereStr = " UserID=" + ctrID + " AND ModuleID=" + ModuleID;

            IList<Base_PrivilegeEntity> peList = DataProvider.GetInstance().GetBase_PrivilegeList(whereStr);

            List<int> idsAlreadyExist = new List<int>();

            if (peList != null && peList.Count > 0)
            {
                foreach (Base_PrivilegeEntity item in peList)
                {
                    idsAlreadyExist.Add(item.ID);
                }
            }



            bool isFind = false;
            List<int> todeleteIDS = new List<int>();
            List<int> tonewIDS = new List<int>();
            #region 要删除的
            for (int i = 0; i < idsAlreadyExist.Count; i++)
            {
                for (int j = 0; j < idsArray.Length; j++)
                {
                    if (idsAlreadyExist[i] == idsArray[j])
                    {
                        isFind = true;
                    }
                }
                if (!isFind)
                {
                    todeleteIDS.Add(idsAlreadyExist[i]);
                }
            }
            #endregion
            #region 要新增的
            for (int i = 0; i < idsArray.Length; i++)
            {
                for (int j = 0; j < idsAlreadyExist.Count; j++)
                {
                    if (idsArray[i] == idsAlreadyExist[j])
                    {
                        isFind = true;
                    }
                }
                if (!isFind)
                {
                    tonewIDS.Add(idsArray[i]);
                }
            }
            #endregion

            if (todeleteIDS.Count > 0)
            {
                foreach (int item in todeleteIDS)
                {
                    DataProvider.GetInstance().DeleteBase_Privilege(item);
                }
            }
            if (tonewIDS.Count > 0)
            {
                foreach (int item in tonewIDS)
                {
                    Base_PrivilegeEntity pe = new Base_PrivilegeEntity();
                    pe.ButtonID = item;
                    pe.ModuleID = ModuleID;
                    pe.UserID = int.Parse(ctrID);
                    pe.CreaterID = CurrentUser.ID;
                    pe.UpdaterID = CurrentUser.ID;
                    pe.CreateDate = DateTime.Now;
                    pe.UpdateDate = DateTime.Now;
                    DataProvider.GetInstance().AddBase_Privilege(pe);
                }
            }
            Alert("授权完成。");
        }
        private MideFrameWork.Data.Entity.Base_PrivilegeEntity GetBase_Privilege(DataRow dr)
        {
            MideFrameWork.Data.Entity.Base_PrivilegeEntity info = new MideFrameWork.Data.Entity.Base_PrivilegeEntity();
										if(DBNull.Value==dr["ID"])
					info.ID=0;
				else
					info.ID=int.Parse(dr["ID"].ToString());
									
																						if(DBNull.Value==dr["UserID"])
					info.UserID=0;
				else
					info.UserID=int.Parse(dr["UserID"].ToString());
									
																						if(DBNull.Value==dr["ModuleID"])
					info.ModuleID=0;
				else
					info.ModuleID=int.Parse(dr["ModuleID"].ToString());
									
																						if(DBNull.Value==dr["ButtonID"])
					info.ButtonID=0;
				else
					info.ButtonID=int.Parse(dr["ButtonID"].ToString());
									
																						if(DBNull.Value==dr["CreaterID"])
					info.CreaterID=0;
				else
					info.CreaterID=int.Parse(dr["CreaterID"].ToString());
									
																						if(DBNull.Value==dr["UpdaterID"])
					info.UpdaterID=0;
				else
					info.UpdaterID=int.Parse(dr["UpdaterID"].ToString());
									
																									if(DBNull.Value==dr["CreateDate"])
					info.CreateDate=DateTime.Now;
				else
					info.CreateDate=DateTime.Parse(dr["CreateDate"].ToString());
						
																									if(DBNull.Value==dr["UpdateDate"])
					info.UpdateDate=DateTime.Now;
				else
					info.UpdateDate=DateTime.Parse(dr["UpdateDate"].ToString());
						
															            return info;
        }