Esempio n. 1
0
    private void Update_GV()
    {
        string ConnectionDB = ((DatabaseSettings)ConfigurationSettings.GetConfig("dataConfiguration")).DefaultDatabase;
        SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

        #region 取得更新前舊值

        #region 使用XML轉回DataSet

        DataSet Ds = new DataSet();
        System.IO.StringReader sr = new System.IO.StringReader(ProgOLDData.InnerHtml);
        Ds.ReadXml(sr);
        DataTable Dt = Ds.Tables[0];

        #endregion

        if (Ds.Tables[0].Rows.Count == 0)
        {
            throw new Exception("抓取不到舊值,更新失敗!");
        }

        #endregion
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {

            #region 加入更新條件
            ParameterList.Clear();

            //舊值
            ParameterList.Add(Dt.Rows[i]["ID"]);
            ParameterList.Add(Dt.Rows[i]["CODE"]);
            ParameterList.Add(Dt.Rows[i]["NAME"]);
            ParameterList.Add(Dt.Rows[i]["CREATEDATE"]);
            ParameterList.Add(Dt.Rows[i]["CREATEUID"]);
            ParameterList.Add(Dt.Rows[i]["UPDATEDATE"]);
            ParameterList.Add(Dt.Rows[i]["UPDATEUID"]);
            ParameterList.Add(Dt.Rows[i]["ENABLE"]);
            ParameterList.Add(Dt.Rows[i]["USERCODE"]);
            ParameterList.Add(Dt.Rows[i]["SYSTEMCODE"]);
            ParameterList.Add(Dt.Rows[i]["PROGRAMCODE"]);
            ParameterList.Add(Dt.Rows[i]["CANCREATE"]);
            ParameterList.Add(Dt.Rows[i]["CANREAD"]);
            ParameterList.Add(Dt.Rows[i]["CANUPDATE"]);
            ParameterList.Add(Dt.Rows[i]["CANDELETE"]);

            //需要更新值
            int enable = 0;
            int create = 0;
            int read = 0;
            int update = 0;
            int delete = 0;
            if (((CheckBox)GridView1.Rows[i].FindControl("chk_Enable")).Checked)
            {
                enable = 1;
            }
            if (((CheckBox)GridView1.Rows[i].FindControl("chk_Create")).Checked)
            {
                create = 1;
            }
            if (((CheckBox)GridView1.Rows[i].FindControl("chk_Read")).Checked)
            {
                read = 1;
            }
            if (((CheckBox)GridView1.Rows[i].FindControl("chk_Update")).Checked)
            {
                update = 1;
            }
            if (((CheckBox)GridView1.Rows[i].FindControl("chk_Delete")).Checked)
            {
                delete = 1;
            }
            DateTime processtime = DateTime.Now;            
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(enable);//enable
            ParameterList.Add(create);//create
            ParameterList.Add(read);//read
            ParameterList.Add(update);//update
            ParameterList.Add(delete);//delete      

            #endregion

            int Result = BCO.UpdateProgramList(ParameterList, null);

            if (Result == 0)
            {
                ErrorMsgLabel.Text = "XX";
            }
            else
            {
                ErrorMsgLabel.Text = "OK";
            }
        }
    }
Esempio n. 2
0
    }//end EditCancelButton_Click

    /// <summary>
    ///  編輯模式,按下更新確認鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void EditCommitButton_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";
            int UpdateRecord = 0;

            #region 取得畫面元件的值

            string v_Name = ((TextBox)FormView1.FindControl("TextBoxName")).Text.Trim();
            DateTime processtime = DateTime.Now;
            string v_UserCode = ((WUI.SLP.User)this.FormView1.FindControl("SLP_UserCode")).Text;
            string v_SystemCode = "VDS2G";//string v_SystemCode = ((TextBox)FormView1.FindControl("TextBoxSystemCode")).Text;
            string v_ProgramCode = ((WUI.SLP.Program)this.FormView1.FindControl("SLP_ProgramCode")).Text;
            string v_CanCreate = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanCreate")).Text.Trim();
            string v_CanRead = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanRead")).Text.Trim();
            string v_CanUpdate = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanUpdate")).Text.Trim();
            string v_CanDelete = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanDelete")).Text.Trim();
            string v_Enable = "1";// ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_Enable")).Text.Trim();

            #endregion

            #region 取得更新前舊值

            #region 使用XML轉回DataSet
            DataSet Ds = new DataSet();
            DataTable Dt = dt_Result;       
            #endregion

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("抓取不到舊值,更新失敗!");
            }

            #endregion

            #region 加入更新條件

            ParameterList.Clear();

            //舊值          
            ParameterList.Add(Dt.Rows[0]["NAME"]);
            ParameterList.Add(Dt.Rows[0]["CREATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["CREATEUID"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEUID"]);
            ParameterList.Add(Dt.Rows[0]["ENABLE"]);
            ParameterList.Add(Dt.Rows[0]["USERCODE"]);
            ParameterList.Add(Dt.Rows[0]["SYSTEMCODE"]);
            ParameterList.Add(Dt.Rows[0]["PROGRAMCODE"]);
            ParameterList.Add(Dt.Rows[0]["CANCREATE"]);
            ParameterList.Add(Dt.Rows[0]["CANREAD"]);
            ParameterList.Add(Dt.Rows[0]["CANUPDATE"]);
            ParameterList.Add(Dt.Rows[0]["CANDELETE"]);


            //需要更新值
            ParameterList.Add(v_Name);
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(v_UserCode);
            ParameterList.Add(v_SystemCode);
            ParameterList.Add(v_ProgramCode);
            ParameterList.Add(int.Parse(v_CanCreate));
            ParameterList.Add(int.Parse(v_CanRead));
            ParameterList.Add(int.Parse(v_CanUpdate));
            ParameterList.Add(int.Parse(v_CanDelete));
            ParameterList.Add(int.Parse(v_Enable));

            #endregion

            SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

            UpdateRecord = BCO.UpdateUserprogauthrel(ParameterList, null);

            if (UpdateRecord == 0)
            {
                throw new Exception("更新0筆資料!");
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "SYS162", "<script>alert('更新完成');</script>");
                ChangeFormMode(FormViewMode.ReadOnly);              
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Esempio n. 3
0
    }//end InsertCancelButton_Click


    /// <summary>
    /// 由新增模式,確認新增
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void InsertButton_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";
            int AddRecord = 0;

            #region 取得畫面元件的值

            string v_Code = "";// ((WUI.SLP.SLPUnique)FormView1.FindControl("TextBoxCode")).Text.Trim();
            string v_Name = ((TextBox)FormView1.FindControl("TextBoxName")).Text.Trim();
            DateTime processtime = DateTime.Now;
            string v_UserCode = ((WUI.SLP.User)this.FormView1.FindControl("SLP_UserCode")).Text;
            string v_SystemCode = "VDS2G";//((TextBox)FormView1.FindControl("TextBoxSystemCode")).Text;
            string v_ProgramCode = ((WUI.SLP.Program)this.FormView1.FindControl("SLP_ProgramCode")).Text;
            string v_CanCreate = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanCreate")).Text.Trim();
            string v_CanRead = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanRead")).Text.Trim();
            string v_CanUpdate = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanUpdate")).Text.Trim();
            string v_CanDelete = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_CanDelete")).Text.Trim();

            //SYSModel.MaintainUser BCO1 = new SYSModel.MaintainUser(ConnectionDB);
            //ParameterList.Clear();
            //ParameterList.Add(v_UserCode);
            //DataTable Chkuser = BCO1.QueryUserByCode(ParameterList);
            //if (Chkuser.Rows.Count != 1)
            //{
            //    ErrorMsgLabel.Text = "請輸入正確人員代號";
            //    return;
            //}

            SYSModel.MaintainUserprogauthrel Uniq = new SYSModel.MaintainUserprogauthrel(ConnectionDB);
            ParameterList.Clear();    
            ParameterList.Add(v_UserCode);
            ParameterList.Add(v_ProgramCode);            
            DataTable Dup = Uniq.QueryDup(ParameterList);

            if (Dup.Rows.Count > 0)
            {
                if (Dup.Rows[0]["ENABLE"].ToString() == "1")
                {
                    throw new Exception("資料重覆!");
                }
            }
            #endregion

            #region 加入輸入條件

            ParameterList.Clear();

            ParameterList.Add(v_Code);
            ParameterList.Add(v_Name);
            ParameterList.Add(processtime);               //vCreateDate
            ParameterList.Add(Session["UID"].ToString()); //vCreateUID
            ParameterList.Add(processtime);               //vUpdateDate
            ParameterList.Add(Session["UID"].ToString()); //vUpdateUID
            ParameterList.Add(v_UserCode);
            ParameterList.Add(v_SystemCode);
            ParameterList.Add(v_ProgramCode);
            ParameterList.Add(1);
            ParameterList.Add(v_CanCreate);
            ParameterList.Add(v_CanRead);
            ParameterList.Add(v_CanUpdate);
            ParameterList.Add(v_CanDelete);

            #endregion

            SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConnectionDB);
            AddRecord = BCO.CreateUserprogauthrel(ParameterList, null);

            if (AddRecord == 0)
            {
                throw new Exception("新增0筆資料!");
            }
            else
            {
                Response.Write("<script>alert('新增完成');location.replace('SYS162.aspx?mode=readonly&ID=" + AddRecord + "');</script>");
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }
Esempio n. 4
0
    }//end EditButton_Click


    #region Gridview1
    private void Programbind()
    {
        string ConnectionDB = ((DatabaseSettings)ConfigurationSettings.GetConfig("dataConfiguration")).DefaultDatabase;
        SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

        ParameterList.Clear();
        ParameterList.Add(this.hiddenUSER.Value);
        DataTable Dt = BCO.QueryProgramList(ParameterList);

        ProgOLDData.InnerHtml = Dt.DataSet.GetXml();

        GridView1.DataSource = Dt;

        GridView1.PageSize = 10;
        GridView1.PageIndex = 0;
        GridView1.DataBind();
    }
Esempio n. 5
0
    private void Loaddata(string NewCode)
    {
        SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConnectionDB);
        ParameterList.Clear();
        ParameterList.Add(NewCode);
        DataTable Dt = BCO.QueryUserprogauthrelByID(ParameterList);

        if (Dt != null)
        {
            if (Dt.Rows.Count == 0)
            {
                ArrayList AL = (ArrayList)Session["SYS16_SortKey" + Request.QueryString["SYS162_PageTimeStamp"]];

                string strRemove = "id=" + NewCode;
                AL.Remove(strRemove);
                Session["SYS16_SortKey" + Request.QueryString["SYS162_PageTimeStamp"]] = AL;

                throw new Exception("此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!");
            }
        }
    }
Esempio n. 6
0
    /// <summary>
    /// 取得所有Master資料以巡覽
    /// </summary>
    private void GetAllMasterRecordsForBrowse()
    {
        #region
        SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConnectionDB);
        DataTable dtTemp = BCO.QueryUserprogauthrelByALL();
        DataView dvForBrowse = dtTemp.DefaultView;
        dtForBrowse = dvForBrowse.ToTable();

        #endregion
    }
Esempio n. 7
0
    /// <summary>
    /// 於檢視模式,按下刪除鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DeleteButton_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";
            int DeleteRecord = 0;

            #region 取得畫面元件的值


            DateTime processtime = DateTime.Now;

            #endregion

            #region 取得刪除前舊值


            #region 使用XML轉回DataSet
            DataSet Ds = new DataSet();
            DataTable Dt = dt_Result;  
            #endregion

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("抓取不到舊值,更新失敗!");
            }

            #endregion

            #region 加入更新條件

            ParameterList.Clear();
            //舊值

            ParameterList.Add(Dt.Rows[0]["ID"]);
            ParameterList.Add(Dt.Rows[0]["CODE"]);
            ParameterList.Add(Dt.Rows[0]["NAME"]);
            ParameterList.Add(Dt.Rows[0]["CREATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["CREATEUID"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEUID"]);
            ParameterList.Add(Dt.Rows[0]["ENABLE"]);
            ParameterList.Add(Dt.Rows[0]["USERCODE"]);
            ParameterList.Add(Dt.Rows[0]["SYSTEMCODE"]);
            ParameterList.Add(Dt.Rows[0]["PROGRAMCODE"]);
            ParameterList.Add(Dt.Rows[0]["CANCREATE"]);
            ParameterList.Add(Dt.Rows[0]["CANREAD"]);
            ParameterList.Add(Dt.Rows[0]["CANUPDATE"]);
            ParameterList.Add(Dt.Rows[0]["CANDELETE"]);

            //需要更新值
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());
            #endregion

            SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

            DeleteRecord = BCO.DeleteUserprogauthrel(ParameterList, null);

            if (DeleteRecord == 0)
            {
                throw new Exception("刪除失敗!");
            }
            else
            {
                Response.Write("<script>alert('刪除完成');location.replace('SYS161.aspx?Code=SYS16');</script>");
            }

            ChangeFormMode(FormViewMode.ReadOnly);

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Esempio n. 8
0
    /// <summary>
    /// 繫結資料
    /// </summary>
    /// <param name=VirtualDataID></param>
    private void databind(FormViewMode fvm)
    {
        try
        {
            SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

            ParameterList.Clear();
            if (Request["ID"] != null)
                ParameterList.Add(Request["ID"].ToString());
            else
                ParameterList.Add("0");

            dt_Result = BCO.QuerySwitch(SYSModel.MaintainUserprogauthrel.QueryType.ID,
                                           ParameterList
                                           );
            if (dt_Result.Rows.Count > 0)
            {
                this.hiddenID.Value = dt_Result.Rows[0]["ID"].ToString();
                this.hiddenUSER.Value = dt_Result.Rows[0]["USERCODE"].ToString();

                FormView1.DataSource = dt_Result;
                FormView1.DataBind();
            }

            AuthorityControls(this);

            //ToolBarStatus
            switch (fvm)
            {
                case FormViewMode.Edit:
                    ToolBarStatus("edit");
                    break;
                case FormViewMode.Insert:
                    ToolBarStatus("insert");
                    break;
                case FormViewMode.ReadOnly:
                    ToolBarStatus("readonly");
                    break;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }//databind
Esempio n. 9
0
    /// <summary>
  /// 處理權限
  /// </summary>
    private void ProcessAuthority()
    {
      try
      {
          bool PageCanCreate = false;
          bool PageCanRead = false;
          bool PageCanUpdate = false;
          bool PageCanDelete = false;

          if (_PageProgramCode != null) //有給PageProgramCode 使用Page
          {
              SYSModel.MaintainUserprogauthrel PermissionProcess = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

              #region 輸入參數

              ParameterList.Clear();
              //使用者
              ParameterList.Add(Session["UID"].ToString());
              //功能代碼
              ParameterList.Add(_PageProgramCode);              

              #endregion

              DataTable Dt = PermissionProcess.QueryPermissionByUser(ParameterList);

              if (Dt.Rows.Count > 0)
              {
                  PageCanCreate = (Dt.Rows[0]["CanCreate"].ToString() == "1") ? true : false;
                  PageCanRead = (Dt.Rows[0]["CanRead"].ToString() == "1") ? true : false;
                  PageCanUpdate = (Dt.Rows[0]["CanUpdate"].ToString() == "1") ? true : false;
                  PageCanDelete = (Dt.Rows[0]["CanDelete"].ToString() == "1") ? true : false;
              }
          }
          else
          {
              PageCanCreate = ((WUI.BaseSecurePage)Page).CanCreate;
              PageCanRead = ((WUI.BaseSecurePage)Page).CanRead;
              PageCanUpdate = ((WUI.BaseSecurePage)Page).CanUpdate;
              PageCanDelete = ((WUI.BaseSecurePage)Page).CanDelete;
          }

          //管理員
          if (Session["UID"].ToString() == "admin")
          {
              PageCanCreate = true;
              PageCanRead = true;
              PageCanUpdate = true;
              PageCanDelete = true;
          }

          #region 無新增權限

          if (!PageCanCreate)
          {
              BtnNewEnable = false;
              BtnCopyEnable = false;              
          }

          #endregion

          #region 無讀取權限

          if (!PageCanRead)
          {
              BtnFindEnable = false;
              BtnFindExportEnable = false;

              BtnRecFirstEnable = false;
              BtnRecPreEnable = false;
              BtnRecNextEnable = false;
              BtnRecLastEnable = false;
          }

          #endregion

          #region 無更新權限

          if (!PageCanUpdate)
          {
              BtnEditEnable = false;              
          }

          #endregion

          #region 無刪除權限

          if (!PageCanDelete)
          {
              BtnDeleteEnable = false;
          }

          #endregion

          #region 儲存必須獨立判斷

          if (PageCanCreate || PageCanUpdate)
          {
              //由現在狀況判斷是否要開啟SAVE
              BtnSaveEnable = BtnSave.Enabled && true;
          }
          else
          {
              BtnSaveEnable = false;
          }

          #endregion

      }
      catch (Exception ex)
      {
          throw ex;
      }
    }
Esempio n. 10
0
    /// <summary>
    /// 抓取功能號權限
    /// </summary>
    /// <param name="FunctionID">功能號代碼</param>
    /// <returns>回傳功能號權限資料</returns>
    private DataTable GetFuncCRUD(string FunctionID)
    {
        DataTable ReturnDt = new DataTable();
        DataColumn Dc = new DataColumn("CanCreate");
        ReturnDt.Columns.Add(Dc);
        DataColumn Dc1 = new DataColumn("CanRead");
        ReturnDt.Columns.Add(Dc1);
        DataColumn Dc2 = new DataColumn("CanUpdate");
        ReturnDt.Columns.Add(Dc2);
        DataColumn Dc3 = new DataColumn("CanDelete");
        ReturnDt.Columns.Add(Dc3);



        //如果是管理員
        if (Session["UID"].ToString() == "admin")
        {
            DataRow Dr = ReturnDt.NewRow();

            Dr["CanCreate"] = true;
            Dr["CanRead"] = true;
            Dr["CanUpdate"] = true;
            Dr["CanDelete"] = true;

            ReturnDt.Rows.Add(Dr);
        }
        else
        {
            SYSModel.MaintainUserprogauthrel PermissionProcess = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

            #region 輸入變數

            ParameterList.Clear();
            //使用者
            ParameterList.Add(Session["UID"].ToString());
            //功能代碼
            ParameterList.Add(FunctionID);

            #endregion

            DataTable Dt = PermissionProcess.QueryPermissionByUser(ParameterList);

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("找不到" + FunctionID + "的權限!");
            }
            else
            {
                DataRow Dr = ReturnDt.NewRow();

                Dr["CanCreate"] = (Dt.Rows[0]["CanCreate"].ToString() == "1") ? true : false;
                Dr["CanRead"] = (Dt.Rows[0]["CanRead"].ToString() == "1") ? true : false;
                Dr["CanUpdate"] = (Dt.Rows[0]["CanUpdate"].ToString() == "1") ? true : false;
                Dr["CanDelete"] = (Dt.Rows[0]["CanDelete"].ToString() == "1") ? true : false;

                ReturnDt.Rows.Add(Dr);

            }

        }

        return ReturnDt;
    }        
Esempio n. 11
0
        /// <summary>
        /// 設定網頁功能權限
        /// </summary>
        private void SetPageCRUD()
        {
            string URLStr = Request.ServerVariables["URL"].ToString();
            string[] WebPageName = URLStr.Split('/');
            string WebPage = WebPageName[WebPageName.Length - 1];

            SYSModel.MaintainUserprogauthrel PermissionProcess = new SYSModel.MaintainUserprogauthrel(ConnectionDB);


            if (Request.QueryString["Code"] != null)
            {                
                #region 輸入變數

                ParameterList.Clear();
                //使用者
                ParameterList.Add(Session["UID"].ToString());
                //功能代碼
                if (Request.QueryString["Code"].ToString().Length < 5)
                {
                    ParameterList.Add(Request.QueryString["Code"].ToString());
                }
                else
                {
                    ParameterList.Add(Request.QueryString["Code"].ToString().Substring(0, 5));
                }

                #endregion                
            }
            else
            {
                #region 輸入變數

                ParameterList.Clear();
                //使用者
                ParameterList.Add(Session["UID"].ToString());
                //功能代碼
                ParameterList.Add(WebPage.ToString().Substring(0, 5));

                #endregion                                
            }

            if (isnumeric(WebPage.Substring(3,1))) //如果是程式頁(第4碼為數字)
            {                
                //如果是管理員
                if (Session["UID"].ToString() == __AdminUser)
                {
                    _CanCreate = true;
                    _CanRead = true;
                    _CanUpdate = true;
                    _CanDelete = true;
                }
                else
                {
                    DataTable Dt = PermissionProcess.QueryPermissionByUser(ParameterList);

                    if (Dt.Rows.Count > 0)
                    {
                        _CanCreate = (Dt.Rows[0]["CanCreate"].ToString() == "1") ? true : false;
                        _CanRead = (Dt.Rows[0]["CanRead"].ToString() == "1") ? true : false;
                        _CanUpdate = (Dt.Rows[0]["CanUpdate"].ToString() == "1") ? true : false;
                        _CanDelete = (Dt.Rows[0]["CanDelete"].ToString() == "1") ? true : false;
                    }
                }
            }

        }
Esempio n. 12
0
    /// <summary>
    /// 查詢資料庫取得資料
    /// </summary> 
    private void databind()
    {
        //抓取本頁初次登記的時間
        string SessionIDName = "SYS161_" + PageTimeStamp.Value;

        SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConntionDB);

        ParameterList.Clear();
        ParameterList.Add("");//ParameterList.Add(TextBoxCode.Text.Trim());
        ParameterList.Add(TextBoxName.Text.Trim());
        ParameterList.Add(TextBoxCreateDate.StartDate.Trim());
        ParameterList.Add(TextBoxCreateDate.EndDate.Trim());
        ParameterList.Add(TextBoxCreateUID.Text.Trim());
        ParameterList.Add(TextBoxUpdateDate.StartDate.Trim());
        ParameterList.Add(TextBoxUpdateDate.EndDate.Trim());
        ParameterList.Add(TextBoxUpdateUID.Text.Trim());
        ParameterList.Add(TextBoxUserCode.Text.Trim());
        ParameterList.Add(TextBoxProgramCode.Text.Trim());
        ParameterList.Add(""); //ParameterList.Add(TextBoxSystemCode.Text.Trim());
        ParameterList.Add(SLP_CanCreate.Text);
        ParameterList.Add(SLP_CanDelete.Text);
        ParameterList.Add(SLP_CanRead.Text);
        ParameterList.Add(SLP_CanUpdate.Text);
        ParameterList.Add("1");//SLP_Enable.Text);
        ParameterList.Add(TextBoxRowCountLimit.Text.Trim());

        DataTable Dt = BCO.QueryRow(ParameterList, CheckBoxLikeSearch.Checked);
 
        Session[SessionIDName] = Dt;
        GridView1.DataSource = Dt;
        //設定分頁大小
        if (TextBoxPagesize.Text == "0")
        {
            GridView1.PageSize = 1;
        }
        else
        {
            GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        }
        GridView1.PageIndex = 0;
        GridView1.DataBind();

        #region 將Key值存到Session中

        ArrayList arl_Key = new ArrayList();

        foreach (DataRow drRow in Dt.Rows)
        { arl_Key.Add("id=" + drRow["ID"].ToString()); }

        Session["SYS16_SortKey" + this.PageTimeStamp.Value] = arl_Key;

        #endregion

        if (Dt.Rows.Count == 0)
        { this.ErrorMsgLabel.Text = "查無資料"; }
    }
Esempio n. 13
0
    /// <summary>
    /// 存檔
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        switch (this.hid_PageStatus.Value)
        {
            case "EDIT":

                #region  處理修改作業
                try
                {
                    ErrorMsgLabel.Text = "";

                    if (GridView1.Rows.Count <= 0)
                    {
                        ErrorMsgLabel.Text = "無資料";
                        return;
                    }
                    else
                    {
                        SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

                        #region 取得更新前舊值

                        #region 使用XML轉回DataSet
                        DataTable dtDetailOLD = dt_Result;

                        #endregion

                        if (dtDetailOLD.Rows.Count == 0)
                        {
                            throw new Exception("抓取不到舊值,更新失敗!");
                        }

                        #endregion

                        BCO.UpdateMaster(this.getMasterParameterList(), this.getDetailData(), null, dtDetailOLD);

                        //由檢視模式切換至編輯模式
                        this.hid_PageStatus.Value = "VIEW";

                        SetPageStatus();

                        databind();
                    }

                }
                catch (Exception ex)
                {                 
                    ErrorMsgLabel.Text = ex.Message;
                }
                #endregion

                break;
            default:
                break;
        }

        GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.Other;
        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "SYS16A.aspx?mode=VIEW&Code=SYS16&USER="******"&ID=" + user_id, null, WUI_GMToolbarV.ClickAction.LinkURL);
        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, true, string.Empty, this.btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick);

        EnableSelectAll();
    }
Esempio n. 14
0
    }//PrepDefaultValue

    private void databind()
    {
        #region      

        ErrorMsgLabel.Text = "";

        //抓取本頁初次登記的時間

        SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);

        SYSModel.MaintainUserprogauthrel BCO = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

        ParameterList.Clear();

        ParameterList.Add(GetValueSetParameter(this.SLP_USERCODE.Text, "string", false));
        ParameterList.Add(ddl_Module2.SelectedValue);

        DataTable Dt = BCO.QueryProgramHierarchyByUser(ParameterList);

        #region 使用XML放置到前端資料   
        #endregion

        dt_Result = Dt;

        //DataRow[] drs = Dt.Select(string.Format("PROGRAMCODE='{0}'", ddl_Module2.SelectedValue));
        //if (drs.Length == 0)
        //{
        //    DataRow dr = Dt.NewRow();
        //    dr["SYSTEMCODE"] = "VDS2G";
        //    dr["PROGRAMCODE"] = ddl_Module2.SelectedValue;
        //    dr["PROGRAMNAME"] = ddl_Module2.SelectedItem.Text;
        //    dr["PARENTCODE"] = ddl_Module2.SelectedValue.Substring(0, 3).ToString();
        //    dr["USERCODE"] = this.SLP_USERCODE.Text;
        //    dr["ENABLE"] = 1;
        //    dr["CANCREATE"] = 0;
        //    dr["CANREAD"] = 1;
        //    dr["CANUPDATE"] = 0;
        //    dr["CANDELETE"] = 0;
        //    dr["CREATEDATE"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
        //    dr["CREATEUID"] = Session["UID"].ToString();
        //    dr["UPDATEDATE"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
        //    dr["UPDATEUID"] = Session["UID"].ToString();
        //    Dt.Rows.InsertAt(dr, 0);
        //}

        SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);

        Session[SessionIDName] = Dt;
        GridView1.DataSource = Dt;
        GridView1.DataBind();

        if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
        {
            ErrorMsgLabel.Text = "查無資料";
        }
    
        #endregion
    }
Esempio n. 15
0
    protected void GetALO03A_Authority()
    {
        ArrayList ParameterList = new ArrayList();
        ParameterList.Clear();
        ParameterList.Add(Session["UID"].ToString()); //使用者
        ParameterList.Add("ALO03A"); //功能代碼
        PIC.VDS2G.COMMON.SYS.MaintainUserprogauthrel PermissionProcess = new PIC.VDS2G.COMMON.SYS.MaintainUserprogauthrel(ConnectionDB);
        DataTable Dt = PermissionProcess.QueryPermissionByUser(ParameterList);
        if (Dt.Rows.Count > 0)
        {
            CanCalculate = (Dt.Rows[0]["CanCreate"].ToString() == "1" || Dt.Rows[0]["CanUpdate"].ToString() == "1") ? true : false;
         }

         btn_Calculate.Visible = CanCalculate;
    }