コード例 #1
0
        /// <summary>
        /// 以程式代號查程式網址
        /// </summary>
        /// <param name="sPrgNo">程式代號</param>
        /// <returns></returns>
        public static string GetPrgUrlByPNo(string sPrgNo)
        {
            string      str_url = "";
            ezSqlClient ezsql   = new ezSqlClient();

            ezsql.CommandText = "SELECT url_prg FROM z_sys_prg WHERE no_prg = @no_prg";
            ezsql.ParameterAdd("@no_prg", sPrgNo, true);
            str_url = ezsql.GetSelectString("url_prg");
            if (string.IsNullOrEmpty(str_url))
            {
                str_url = "";
            }
            if (!string.IsNullOrEmpty(str_url))
            {
                {
                    str_url = ezSession.FormRoot + "/" + sPrgNo.Substring(0, 3).ToLower() + "/" + str_url + ".aspx";
                    if (!File.Exists(HttpContext.Current.Server.MapPath(str_url)))
                    {
                        str_url = "";
                    }
                }
            }
            ezsql.Close();
            return(str_url);
        }
コード例 #2
0
        public static string GetUserName(string sUserNo)
        {
            string      strUserName = sUserNo;
            ezSqlClient ezsql       = new ezSqlClient();

            ezsql.CommandText = "SELECT mname FROM z_org_user WHERE mno = @mno";
            ezsql.ParameterAdd("@mno", sUserNo, true);
            if (ezsql.HasRows)
            {
                strUserName = ezsql.GetSelectString("mname", false);
            }
            ezsql.Close();
            return(strUserName);
        }
コード例 #3
0
        /// <summary>
        /// 以程式代號查程式名稱
        /// </summary>
        /// <param name="sPrgNo">程式代號</param>
        /// <returns></returns>
        public static string GetPrgNameByPNo(string sPrgNo)
        {
            string      str_name = "";
            ezSqlClient ezsql    = new ezSqlClient();

            ezsql.CommandText = "SELECT name_prg FROM z_sys_prg WHERE no_prg = @no_prg";
            ezsql.ParameterAdd("@no_prg", sPrgNo, true);
            str_name = ezsql.GetSelectString("name_prg");
            if (string.IsNullOrEmpty(str_name))
            {
                str_name = "";
            }
            ezsql.Close();
            return(str_name);
        }
コード例 #4
0
        /// <summary>
        /// Init 自定預設設定值
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        /// <param name="bHeaderText">標題名稱</param>
        public static void Init(object sender, EventArgs e, bool bHeaderText)
        {
            if (bHeaderText)
            {
                object objPrgNo   = HttpContext.Current.Session["PrgNo"];
                object objPrgName = HttpContext.Current.Session["PrgName"];
                string strPrgNo   = (objPrgNo == null) ? "" : objPrgNo.ToString();
                string strPrgName = (objPrgName == null) ? "" : objPrgName.ToString();

                if (string.IsNullOrEmpty(strPrgNo))
                {
                    string str_page_name = System.IO.Path.GetFileName(HttpContext.Current.Request.PhysicalPath);

                    //程式代號及名稱則到資料庫中以網頁名稱查詢
                    ezSession.PrgNo   = "None";
                    ezSession.PrgName = "(未設定)";

                    if (str_page_name.LastIndexOf('.') >= 0)
                    {
                        str_page_name = str_page_name.Substring(0, str_page_name.LastIndexOf('.'));
                    }

                    string      str_url_prg = "%" + str_page_name + "%";
                    ezSqlClient ezsql       = new ezSqlClient();
                    ezsql.CommandText = "SELECT count(*) as counts FROM z_sys_prg WHERE url_prg like @url_prg";
                    ezsql.ParameterAdd("@url_prg", str_url_prg, true);
                    if (ezsql.HasRows)
                    {
                        int int_count = ezsql.GetSelectInt("counts");
                        if (int_count == 1)
                        {
                            ezsql.CommandText = "SELECT no_prg , name_prg FROM z_sys_prg WHERE url_prg like @url_prg";
                            ezsql.ParameterAdd("@url_prg", str_url_prg, true);
                            ezSession.PrgNo   = ezsql.GetSelectString("no_prg");
                            ezSession.PrgName = ezsql.GetSelectString("name_prg");
                            strPrgNo          = ezSession.PrgNo;
                            strPrgName        = ezSession.PrgName;
                        }
                    }
                    ezsql.Close();
                }

                string strHeaderText = (string.IsNullOrEmpty(strPrgNo)) ? "未指定" : strPrgNo + " [" + strPrgName + "]";
                (sender as ASPxRoundPanel).HeaderText = strHeaderText;
            }
            (sender as ASPxRoundPanel).Font.Size          = ezSession.FontSize;
            (sender as ASPxRoundPanel).ShowCollapseButton = false;
        }
コード例 #5
0
        public static bool SetIsPrgSecurity(string sPrgNo)
        {
            bool blnSecurity = false;

            if (ezSession.LoginRole == ezEnum.LoginRole.User)
            {
                string      strUserNo = ezSession.UserNo;
                ezSqlClient ezsql     = new ezSqlClient();
                ezsql.CommandText = "SELECT isadd , isedit , isdelete FROM z_sys_security WHERE user_no = @user_no AND prg_no = @prg_no";
                ezsql.ParameterAdd("@user_no", strUserNo, true);
                ezsql.ParameterAdd("@prg_no", sPrgNo, false);
                blnSecurity = ezsql.HasRows;
                ezsql.Close();
            }
            return(blnSecurity);
        }
コード例 #6
0
        /// <summary>
        /// 以程式代號取得程式位置
        /// </summary>
        /// <param name="strPrgNo">程式代號</param>
        /// <returns></returns>
        public static string GetPrgUrlByPrgNo(string strPrgNo)
        {
            int         intPrgID   = 0;
            string      strPrgUrl  = "";
            string      strPrgName = "";
            ezSqlClient ezsql      = new ezSqlClient();

            ezsql.CommandText = "SELECT rowid , murl , mname FROM z_sys_program WHERE mno = @mno";
            ezsql.ParameterAdd("@mno", strPrgNo, true);
            intPrgID          = ezsql.GetSelectInt("rowid", false);
            strPrgUrl         = ezsql.GetSelectString("murl", false);
            strPrgName        = ezsql.GetSelectString("mname", true);
            ezSession.PrgID   = intPrgID.ToString();
            ezSession.PrgNo   = strPrgNo;
            ezSession.PrgName = strPrgName;
            return(strPrgUrl);
        }
コード例 #7
0
        public static bool SetIsModuleSecurity(string sModuleNo)
        {
            bool blnSecurity = false;

            if (ezSession.LoginRole == ezEnum.LoginRole.User)
            {
                string      strUserNo = ezSession.UserNo;
                ezSqlClient ezsql     = new ezSqlClient();
                ezsql.CommandText  = "SELECT module.mno FROM  z_sys_security INNER JOIN ";
                ezsql.CommandText += "z_sys_program AS prg ON z_sys_security.prg_no = prg.mno INNER JOIN ";
                ezsql.CommandText += "z_sys_program AS module ON prg.parentid = module.rowid ";
                ezsql.CommandText += "WHERE (z_sys_security.user_no = @user_no) AND (module.mno = @module_no) AND (prg.mcode = N'1') AND ";
                ezsql.CommandText += "(prg.mlevel = '2') AND (module.mcode = N'1') AND (module.mlevel = '1')";
                ezsql.ParameterAdd("@user_no", strUserNo, true);
                ezsql.ParameterAdd("@module_no", sModuleNo, false);
                blnSecurity = ezsql.HasRows;
                ezsql.Close();
            }
            return(blnSecurity);
        }
コード例 #8
0
        public static bool SetSecurity(string sPrgNo)
        {
            bool blnSecurity = false;

            ezSession.IsAdd      = ezEnum.YesNo.No;
            ezSession.IsEdit     = ezEnum.YesNo.No;
            ezSession.IsDelete   = ezEnum.YesNo.No;
            ezSession.IsConfirm  = ezEnum.YesNo.No;
            ezSession.IsPrice    = ezEnum.YesNo.No;
            ezSession.IsPrint    = ezEnum.YesNo.No;
            ezSession.IsDownload = ezEnum.YesNo.No;
            ezSession.IsAbolish  = ezEnum.YesNo.No;
            ezSession.IsExport   = ezEnum.YesNo.No;

            if (ezSession.LoginRole == ezEnum.LoginRole.User)
            {
                string      strUserNo = ezSession.UserNo;
                ezSqlClient ezsql     = new ezSqlClient();
                ezsql.CommandText  = "SELECT isadd , isedit , isdelete , isconfirm , isprint , isexport ";
                ezsql.CommandText += "FROM z_sys_security WHERE user_no = @user_no AND prg_no = @prg_no";
                ezsql.ParameterAdd("@user_no", strUserNo, true);
                ezsql.ParameterAdd("@prg_no", sPrgNo, false);
                blnSecurity = ezsql.HasRows;
                if (blnSecurity)
                {
                    ezSession.IsAdd     = (ezsql.GetSelectString("isadd") == "1") ? ezEnum.YesNo.Yes : ezEnum.YesNo.No;
                    ezSession.IsEdit    = (ezsql.GetSelectString("isedit") == "1") ? ezEnum.YesNo.Yes : ezEnum.YesNo.No;
                    ezSession.IsDelete  = (ezsql.GetSelectString("isdelete") == "1") ? ezEnum.YesNo.Yes : ezEnum.YesNo.No;
                    ezSession.IsConfirm = (ezsql.GetSelectString("isconfirm") == "1") ? ezEnum.YesNo.Yes : ezEnum.YesNo.No;
                    ezSession.IsPrint   = (ezsql.GetSelectString("isprint") == "1") ? ezEnum.YesNo.Yes : ezEnum.YesNo.No;
                    ezSession.IsExport  = (ezsql.GetSelectString("isexport") == "1") ? ezEnum.YesNo.Yes : ezEnum.YesNo.No;
                }
                ezsql.Close();
            }
            return(blnSecurity);
        }
コード例 #9
0
        /// <summary>
        /// 檢查輸入欄位是否重覆
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        /// <param name="sDataColName">Gridview 中的欄位名稱</param>
        /// <param name="sTableName">要查詢的表格名稱</param>
        /// <param name="sColName">要查詢的表格的欄位名稱</param>
        /// <param name="sDispColName">顯示在Gridview 中的那個欄位</param>
        /// <param name="sWhereString">另要加入的 Where 條件式</param>
        /// <param name="sErrorText">錯誤訊息 , 空白為顯示 [不可重覆輸入!!]</param>
        /// <param name="bShowInColumn">錯誤訊息是否顯示在欄位後面</param>
        public static void CheckDuplicate(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e, string sDataColName, string sTableName, string sColName, string sDispColName, string sWhereString, string sErrorText, bool bShowInColumn)
        {
            int    int_data = 0;
            string str_data = "";
            string str_type = (e.NewValues[sDataColName] == null) ? "" : e.NewValues[sDataColName].GetType().Name;

            //欄位型態不是文字或整數時不判斷
            if (str_type != "String" && str_type != "Int32")
            {
                return;
            }

            //未輸入時不檢查
            if (e.NewValues[sDataColName] == null)
            {
                return;
            }
            if (str_type == "String" && e.NewValues[sDataColName].ToString() == "")
            {
                return;
            }

            //修改時有修改才要判斷重覆
            if (!e.IsNewRow)
            {
                if (e.NewValues[sDataColName] == e.OldValues[sDataColName])
                {
                    return;
                }
            }


            ezSqlClient ezsql = new ezSqlClient();

            ezsql.CommandText = "SELECT " + sDataColName + " FROM " + sTableName + " WHERE " + sColName + " = @new_value ";
            str_data          = (e.NewValues[sDataColName] == null) ? "" : e.NewValues[sDataColName].ToString();
            if (str_type == "String")
            {
                ezsql.ParameterAdd("@new_value", str_data, true);
            }
            if (str_type == "Int32")
            {
                if (string.IsNullOrEmpty(str_data))
                {
                    str_data = "0";
                }
                int_data = int.Parse(str_data);
                ezsql.ParameterAdd("@new_value", int_data, true);
            }
            //修改時要確認不要判斷到同筆,避免誤判
            if (!e.IsNewRow)
            {
                ezsql.CommandText += "AND " + sColName + " <> @old_value ";
                str_data           = (e.OldValues[sDataColName] == null) ? "" : e.OldValues[sDataColName].ToString();
                if (str_type == "String")
                {
                    ezsql.ParameterAdd("@old_value", str_data, false);
                }
                if (str_type == "int")
                {
                    if (string.IsNullOrEmpty(str_data))
                    {
                        str_data = "0";
                    }
                    int_data = int.Parse(str_data);
                    ezsql.ParameterAdd("@old_value", int_data, false);
                }
            }
            if (!string.IsNullOrEmpty(sWhereString))
            {
                ezsql.CommandText += "AND " + sWhereString;
            }
            bool bln_hasrow = ezsql.HasRows;

            ezsql.Close();

            if (string.IsNullOrEmpty(sErrorText))
            {
                sErrorText = "不可重覆輸入!!";
            }
            if (!bShowInColumn && !string.IsNullOrEmpty(sDispColName))
            {
                sErrorText = (sender as ASPxGridView).Columns[sDispColName].Caption + sErrorText;
            }

            if (bln_hasrow)
            {
                if (bShowInColumn && !string.IsNullOrEmpty(sDispColName))
                {
                    AddError(e.Errors, (sender as ASPxGridView).Columns[sDispColName], sErrorText);
                }
                else
                {
                    e.RowError = sErrorText;
                }
            }
        }