示例#1
0
        static public bool CekAkses(string NamaModule, ref bool bolRead,
                                    ref bool bolAdd, ref bool boEdit,
                                    ref bool bolDelete, ref bool bolPrint,
                                    ref bool bolSave, ref bool bolDownload, ref bool bolUpload)
        {
            bool cekAkses;

            cekAkses    = false;
            bolRead     = false;
            bolAdd      = false;
            bolEdit     = false;
            bolDelete   = false;
            bolPrint    = false;
            bolSave     = false;
            bolDownload = false;
            bolUpload   = false;

            using (clsConnection oConn = new clsConnection())
            {
                if (strEmployeeName.ToLower() == "admin" || strGroupUser.ToLower() == "admin")
                {
                    cekAkses    = true;
                    bolRead     = true;
                    bolAdd      = true;
                    boEdit      = true;
                    bolDelete   = true;
                    bolPrint    = true;
                    bolSave     = true;
                    bolDownload = true;
                    bolUpload   = true;
                }
                else
                {
                    if (dtCekAkses == null)
                    {
                        NpgsqlCommand cmd = new NpgsqlCommand();
                        cmd.CommandText = @"SELECT a.usermoduleid, a.userid, a.moduleid, a.isread,
                                    a.isedit, a.isadd, a.isdelete, a.isprint, a.issave, a.isdownload, a.isupload, 
                                    b.module_nama
                                    FROM tbmusermodules a
                                    inner join tbmmodule b on a.moduleid=b.moduleid and b.dlt='0'
                                    Where a.dlt='0' and a.userid='" + strUserID + "'";
                        dtCekAkses      = oConn.GetData(cmd);
                    }
                    foreach (DataRow Npdr in dtCekAkses.Select("module_nama='" + NamaModule.Replace("'", "''") + "'"))
                    {
                        bolRead = Convert.ToBoolean(Npdr["isread"]);
                        if (bolRead == false)
                        {
                            cekAkses = false;
                        }
                        else
                        {
                            cekAkses    = true;
                            bolAdd      = Convert.ToBoolean(Npdr["isadd"]);
                            boEdit      = Convert.ToBoolean(Npdr["isedit"]);
                            bolDelete   = Convert.ToBoolean(Npdr["isdelete"]);
                            bolPrint    = Convert.ToBoolean(Npdr["isprint"]);
                            bolSave     = Convert.ToBoolean(Npdr["issave"]);
                            bolDownload = Convert.ToBoolean(Npdr["isdownload"]);
                            bolUpload   = Convert.ToBoolean(Npdr["isupload"]);
                        }
                    }
                }
            }
            return(cekAkses);
        }