public static bool UserAccessPermission(int fileId, int UserID)
        {
            string Access = "D";

            try
            {
                SqlCommand cmd = ConnectSQL.ExecuteCommand("select [Status] from inzFileAccess where USERID=@UserId and FileId=@FileId");
                cmd.Parameters.AddWithValue("@FileId", fileId);
                cmd.Parameters.AddWithValue("@UserId", UserID);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        Access = rdr["Status"].ToString();
                    }
                }



                return(Access == "A");
            }
            catch
            {
                return(false);
            }
        }
        public static string GetFileName(int FileId)
        {
            string FileName = "NIL";

            try
            {
                SqlCommand cmd = ConnectSQL.ExecuteCommand("select [DocumentName] from inz_file Where FileId=@FileId");
                cmd.Parameters.AddWithValue("@FileId", FileId);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        FileName = rdr["DocumentName"].ToString();
                    }
                }



                return(FileName);
            }
            catch
            {
                return(FileName);
            }
        }
        public static List <int> GetFileCount(int UserId)
        {
            List <int> Countlist = new List <int>();

            try
            {
                SqlCommand cmd = ConnectSQL.ExecuteCommand("select [Count] from inz_file_status Where UserId=@UserId");
                cmd.Parameters.AddWithValue("@UserID", UserId);
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Countlist.Add((int)(rdr["Count"]));
                }
                if (Countlist.Count == 0)
                {
                    Countlist.Add(0);
                }

                return(Countlist);
            }
            catch
            {
                Countlist.Add(0);
                return(Countlist);
            }
        }
 public static bool DeleteFile(int fileId)
 {
     try
     {
         SqlCommand cmd = ConnectSQL.ExecuteCommand("Delete from inz_file where FileID=@FileId Delete from inz_file_status where FileID=@FileId");
         cmd.Parameters.AddWithValue("@FileID", fileId);
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 5
0
        public static List <User> UserAllUser(int FileId)
        {
            List <User> userlist = new List <User>();

            try
            {
                SqlCommand cmd = ConnectSQL.ExecuteProcedure("SpFileAccess");
                cmd.Parameters.AddWithValue("@FileId", FileId);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        User user = new User();
                        user.UserID    = (int)rdr["UserID"];
                        user.Username  = rdr["Username"].ToString();
                        user.Rowstatus = Convert.ToChar(rdr["Rowstatus"]);
                        userlist.Add(user);
                    }
                }
                else
                {
                    rdr.Dispose();
                    cmd.Dispose();
                    cmd = ConnectSQL.ExecuteCommand("select UserID,Username,Rowstatus from inz_USERS");
                    rdr = cmd.ExecuteReader();
                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            User user = new User();
                            user.UserID    = (int)rdr["UserID"];
                            user.Username  = rdr["Username"].ToString();
                            user.Rowstatus = Convert.ToChar(rdr["Rowstatus"]);
                            userlist.Add(user);
                        }
                    }
                }



                return(userlist);
            }
            catch
            {
                return(userlist);
            }
        }
Esempio n. 6
0
        public static int GetUserID(string USername)
        {
            int Userid = 0;

            try
            {
                SqlCommand cmd = ConnectSQL.ExecuteCommand("select UserId from inz_USERS Where Username=@Username");
                cmd.Parameters.AddWithValue("@Username", USername);
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Userid = (int)rdr["UserId"];
                }


                return(Userid);
            }
            catch
            {
                return(Userid);
            }
        }