public menu_view_restriction_lib module_access_in(menu_view_restriction_lib[] obj, int company_id, int created_by)
        {
            menu_view_restriction_lib ret = new menu_view_restriction_lib();

            ret.access_level_id = 1;
            SqlConnection  oConn = new SqlConnection(_master);
            SqlTransaction oTrans;

            oConn.Open();
            oTrans = oConn.BeginTransaction();
            SqlCommand oCmd = new SqlCommand();

            oCmd.Connection  = oConn;
            oCmd.Transaction = oTrans;
            try
            {
                oCmd.CommandText = "module_access_del";
                oCmd.CommandType = CommandType.StoredProcedure;
                oCmd.Parameters.Clear();
                oCmd.Parameters.AddWithValue("@access_level_id", obj[0].access_level_id);
                oCmd.Parameters.AddWithValue("@company_id", company_id);
                oCmd.ExecuteNonQuery();

                foreach (var x in obj)
                {
                    oCmd.CommandText = "module_access_in";
                    oCmd.CommandType = CommandType.StoredProcedure;
                    oCmd.Parameters.Clear();
                    oCmd.Parameters.AddWithValue("@module_id", x.module_id);
                    oCmd.Parameters.AddWithValue("@access_level_id", x.access_level_id);
                    oCmd.Parameters.AddWithValue("@created_by", created_by);
                    oCmd.Parameters.AddWithValue("@company_id", company_id);
                    oCmd.Parameters.AddWithValue("@new", x.enable_new);
                    oCmd.Parameters.AddWithValue("@modify", x.enable_modify);
                    oCmd.Parameters.AddWithValue("@views", x.enable_views);
                    oCmd.Parameters.AddWithValue("@prints", x.enable_prints);
                    oCmd.Parameters.AddWithValue("@duplicate", x.enable_duplicate);
                    oCmd.Parameters.AddWithValue("@others1", x.enable_others1);
                    oCmd.Parameters.AddWithValue("@others2", x.enable_others2);
                    oCmd.Parameters.AddWithValue("@others3", x.enable_others3);
                    oCmd.Parameters.AddWithValue("@others4", x.enable_others4);
                    oCmd.Parameters.AddWithValue("@others5", x.enable_others5);
                    oCmd.Parameters.AddWithValue("@viewAll", x.enable_view_all);
                    oCmd.ExecuteNonQuery();
                }
                oTrans.Commit();
            }
            catch (Exception e)
            {
                ret.access_level_id = 0;
                Console.WriteLine("Error: " + e.Message);
                error_log_in("0", "SP = module_access_in | " + e.Message, company_id, created_by);
                oTrans.Rollback();
            }
            finally
            {
                oConn.Close();
            }
            return(ret);
        }
Пример #2
0
        public JsonResult module_access_in(menu_view_restriction_lib[] objHeader)
        {
            int company_id = Convert.ToInt32(Crypto.url_decrypt(Request.Cookies["CompanyId"]));
            int created_by = Convert.ToInt32(Crypto.url_decrypt(Request.Cookies["UserId"]));
            menu_view_restriction_lib result = _master.module_access_inAsync(objHeader, company_id, created_by).Result;
            JsonResult json = Json(result);

            return(json);
        }