示例#1
0
    /// <summary>
    /// 新增我的選單
    /// </summary>
    private void Delete_MenuItem()
    {
        try
        {
            DateTime processtime = DateTime.Now;
            SYSModel.MaintainProgauthrel progth = new SYSModel.MaintainProgauthrel(ConnectionDB);
            DataRow[] rows = ((DataTable)Session["Cust_UserProgramStatus"]).Select(string.Format("CODE = '{0}'", programid));

            if (rows.Length == 1)
            {
                ParameterList.Clear();
                //old
                ParameterList.Add(rows[0]["REL_CODE"]);//Code
                ParameterList.Add(rows[0]["NAME"]);//Name            
                ParameterList.Add(rows[0]["CREATEDATE"]);
                ParameterList.Add(rows[0]["CREATEUID"]);
                ParameterList.Add(rows[0]["UPDATEDATE"]);
                ParameterList.Add(rows[0]["UPDATEUID"]);
                ParameterList.Add(Session["UID"].ToString()); //Userrolecode
                ParameterList.Add(rows[0]["CODE"]);//Programcode
                ParameterList.Add(rows[0]["REL_ENABLE"]);//Programcode
                //new            
                ParameterList.Add(processtime); //UpdateDate
                ParameterList.Add(Session["UID"].ToString()); //UpdateUID      

                int DelRecord = progth.DeleteProgauthrel(ParameterList, null);
                if (DelRecord > 0)
                {
                    ParameterList.Clear();
                    ParameterList.Add(Session["UID"].ToString());
                    DataTable Dt3 = progth.QueryCustProgramForUser(ParameterList);
                    if (Dt3 != null)
                    {
                        Session["Cust_UserProgramStatus"] = Dt3;//更新選單
                    }
                }

                Response.Write("ok$$");
            }
            else
            {
                Response.Write("nothing$$");
            }           
        }
        catch (Exception ex)
        {           
           Response.Write(ex.Message + "$$");
        }
    }
示例#2
0
        /// <summary>
        /// 使用者登入所需作業
        /// </summary>
        /// <param name="UserName">使用者名稱</param>
        public void UserLogin(string UserName)
        {

            

          //記錄使用者ID
          Session["UID"] = UserName;

          //統計人數


          #region 傳入使用者ID

          ParameterList.Clear();
          ParameterList.Add(UserName);

          #endregion

          //載入使用者資訊
          SYSModel.MaintainUser user = new SYSModel.MaintainUser(ConnectionDB);
          Session["UserInfo"] = user.QueryUserByCode(ParameterList);

          //載入使用者功能表單
          SYSModel.MaintainProgram prog = new SYSModel.MaintainProgram(ConnectionDB);
          DataTable Dt = prog.QueryAllProgramForUser(ParameterList);

          SYSModel.MaintainProgauthrel progth = new SYSModel.MaintainProgauthrel(ConnectionDB);
          DataTable Dt2 = progth.QueryCustProgramForUser(ParameterList);
          
          //如果為admin
          if (ParameterList[0].ToString() == __AdminUser)
          {
              for (int i = 0; i < Dt.Rows.Count; i++)
              {
                  Dt.Rows[i]["Status"] = 1;
              }
          }

          Session["UserProgramStatus"] = Dt;
          Session["Cust_UserProgramStatus"] = Dt2;
        }
示例#3
0
    /// <summary>
    /// 新增我的選單
    /// </summary>
    private void Insert_MenuItem()
    {
        try
        {
            SYSModel.MaintainProgauthrel progth = new SYSModel.MaintainProgauthrel(ConnectionDB);

            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());            
            DataTable Dt2 = progth.QueryCustProgramForUser(ParameterList);

            for (int i = 0; i < Dt2.Rows.Count; i++)
            {
                if (Dt2.Rows[i]["PROGRAMCODE"].ToString() == programid)
                {
                    throw new Exception("duplicate"); //已存在
                }
            }

            DateTime processtime = DateTime.Now;
            DataRow[] rows = ((DataTable)Session["UserProgramStatus"]).Select(string.Format("CODE = '{0}' and ISVISUAL = 1", programid));
            string programcode = rows[0]["CODE"].ToString();
            string name = rows[0]["NAME"].ToString();

            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());//Code 
            ParameterList.Add(name);//Name 
            ParameterList.Add(processtime); //CreateDate
            ParameterList.Add(Session["UID"].ToString()); //CreateUID
            ParameterList.Add(processtime); //UpdateDate
            ParameterList.Add(Session["UID"].ToString()); //UpdateUID
            ParameterList.Add(1);//Enable
            ParameterList.Add(1);//userroletype
            ParameterList.Add(Session["UID"].ToString()); //userrolecode
            ParameterList.Add("VDS2G"); //systemcode
            ParameterList.Add(programid); //programcode
            ParameterList.Add(CanCreate);
            ParameterList.Add(CanRead);
            ParameterList.Add(CanUpdate);
            ParameterList.Add(CanDelete);

            int AddRecord = progth.CreateProgauthrel(ParameterList, null);
            if (AddRecord > 0)
            {
                ParameterList.Clear();
                ParameterList.Add(Session["UID"].ToString());
                DataTable Dt3 = progth.QueryCustProgramForUser(ParameterList);
                if (Dt3 != null)
                {
                    Session["Cust_UserProgramStatus"] = Dt3;//更新選單                   
                }                
            }
            
            Response.Write("ok$$");
        }
        catch (Exception ex)
        {
            if (ex.Message == "duplicate")
            {
                Response.Write("duplicate$$");
            }
            else
            {
                Response.Write(ex.Message + "$$");
            }
            
        }        
    }