Example #1
0
        /// <summary>
        /// 删除事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                CheckBox cb;
                int resourceID;
                ExtendBLL.FavoriteResource fr = new ExtendBLL.FavoriteResource();
                LabMS.Model.FavoriteResource frInfo = new LabMS.Model.FavoriteResource();

                for (int i = GridViewResourceList.Rows.Count - 1; i > -1; i--)
                {
                    cb = (CheckBox)GridViewResourceList.Rows[i].FindControl("CBSelect");

                    if (cb.Checked)
                    {
                        resourceID = int.Parse(GridViewResourceList.DataKeys[i].Value.ToString());

                        frInfo.ResourceID = resourceID;
                        frInfo.UserID = int.Parse(UserID);
                        frInfo.UserType = Base.PrivilegeManager.GetUserTypeCode();

                        fr.Delete(frInfo);
                    }
                }

                BindData();

                WriteBackScript("alert('已成功删除相关资源')");
            }
            catch (Exception ex)
            {
            }
        }
Example #2
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.FavoriteResource GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,UserID,ResourceID,UserType from FavoriteResource ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = ID;

            LabMS.Model.FavoriteResource model=new LabMS.Model.FavoriteResource();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["ID"].ToString()!="")
                {
                    model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["UserID"].ToString()!="")
                {
                    model.UserID=int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["ResourceID"].ToString()!="")
                {
                    model.ResourceID=int.Parse(ds.Tables[0].Rows[0]["ResourceID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["UserType"].ToString()!="")
                {
                    model.UserType=int.Parse(ds.Tables[0].Rows[0]["UserType"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }